mirror of
https://github.com/google/googletest.git
synced 2025-12-21 11:04:54 +08:00
Merge branch 'google:master' into master
This commit is contained in:
commit
3015953623
@ -157,8 +157,11 @@ that can be used in the predicate assertion macro
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
EXPECT_PRED_FORMAT2(testing::FloatLE, val1, val2);
|
using ::testing::FloatLE;
|
||||||
EXPECT_PRED_FORMAT2(testing::DoubleLE, val1, val2);
|
using ::testing::DoubleLE;
|
||||||
|
...
|
||||||
|
EXPECT_PRED_FORMAT2(FloatLE, val1, val2);
|
||||||
|
EXPECT_PRED_FORMAT2(DoubleLE, val1, val2);
|
||||||
```
|
```
|
||||||
|
|
||||||
The above code verifies that `val1` is less than, or approximately equal to,
|
The above code verifies that `val1` is less than, or approximately equal to,
|
||||||
@ -1594,6 +1597,7 @@ void RegisterMyTests(const std::vector<int>& values) {
|
|||||||
}
|
}
|
||||||
...
|
...
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
std::vector<int> values_to_test = LoadValuesFromConfig();
|
std::vector<int> values_to_test = LoadValuesFromConfig();
|
||||||
RegisterMyTests(values_to_test);
|
RegisterMyTests(values_to_test);
|
||||||
...
|
...
|
||||||
|
|||||||
@ -591,6 +591,12 @@ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
|
|||||||
|
|
||||||
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
|
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
|
||||||
|
|
||||||
|
#if GTEST_HAS_RTTI
|
||||||
|
inline void PrintTo(const std::type_info& info, std::ostream* os) {
|
||||||
|
*os << internal::GetTypeName(info);
|
||||||
|
}
|
||||||
|
#endif // GTEST_HAS_RTTI
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
|
void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
|
||||||
UniversalPrinter<T&>::Print(ref.get(), os);
|
UniversalPrinter<T&>::Print(ref.get(), os);
|
||||||
|
|||||||
@ -2451,6 +2451,7 @@ GTEST_API_ std::string TempDir();
|
|||||||
// }
|
// }
|
||||||
// ...
|
// ...
|
||||||
// int main(int argc, char** argv) {
|
// int main(int argc, char** argv) {
|
||||||
|
// ::testing::InitGoogleTest(&argc, argv);
|
||||||
// std::vector<int> values_to_test = LoadValuesFromConfig();
|
// std::vector<int> values_to_test = LoadValuesFromConfig();
|
||||||
// RegisterMyTests(values_to_test);
|
// RegisterMyTests(values_to_test);
|
||||||
// ...
|
// ...
|
||||||
|
|||||||
@ -629,7 +629,8 @@ class ThreadLocalRegistryImpl {
|
|||||||
&ThreadLocalRegistryImpl::WatcherThreadFunc,
|
&ThreadLocalRegistryImpl::WatcherThreadFunc,
|
||||||
reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),
|
reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),
|
||||||
CREATE_SUSPENDED, &watcher_thread_id);
|
CREATE_SUSPENDED, &watcher_thread_id);
|
||||||
GTEST_CHECK_(watcher_thread != nullptr);
|
GTEST_CHECK_(watcher_thread != nullptr)
|
||||||
|
<< "CreateThread failed with error " << ::GetLastError() << ".";
|
||||||
// Give the watcher thread the same priority as ours to avoid being
|
// Give the watcher thread the same priority as ours to avoid being
|
||||||
// blocked by it.
|
// blocked by it.
|
||||||
::SetThreadPriority(watcher_thread,
|
::SetThreadPriority(watcher_thread,
|
||||||
|
|||||||
@ -3948,12 +3948,13 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
|
|||||||
private:
|
private:
|
||||||
// Is c a whitespace character that is normalized to a space character
|
// Is c a whitespace character that is normalized to a space character
|
||||||
// when it appears in an XML attribute value?
|
// when it appears in an XML attribute value?
|
||||||
static bool IsNormalizableWhitespace(char c) {
|
static bool IsNormalizableWhitespace(unsigned char c) {
|
||||||
return c == 0x9 || c == 0xA || c == 0xD;
|
return c == '\t' || c == '\n' || c == '\r';
|
||||||
}
|
}
|
||||||
|
|
||||||
// May c appear in a well-formed XML document?
|
// May c appear in a well-formed XML document?
|
||||||
static bool IsValidXmlCharacter(char c) {
|
// https://www.w3.org/TR/REC-xml/#charsets
|
||||||
|
static bool IsValidXmlCharacter(unsigned char c) {
|
||||||
return IsNormalizableWhitespace(c) || c >= 0x20;
|
return IsNormalizableWhitespace(c) || c >= 0x20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -473,6 +473,16 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
|
|||||||
EXPECT_EQ("-2.5", Print(-2.5)); // double
|
EXPECT_EQ("-2.5", Print(-2.5)); // double
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GTEST_HAS_RTTI
|
||||||
|
TEST(PrintBuiltInTypeTest, TypeInfo) {
|
||||||
|
struct MyStruct {};
|
||||||
|
auto res = Print(typeid(MyStruct{}));
|
||||||
|
// We can't guarantee that we can demangle the name, but either name should
|
||||||
|
// contain the substring "MyStruct".
|
||||||
|
EXPECT_NE(res.find("MyStruct"), res.npos) << res;
|
||||||
|
}
|
||||||
|
#endif // GTEST_HAS_RTTI
|
||||||
|
|
||||||
// Since ::std::stringstream::operator<<(const void *) formats the pointer
|
// Since ::std::stringstream::operator<<(const void *) formats the pointer
|
||||||
// output differently with different compilers, we have to create the expected
|
// output differently with different compilers, we have to create the expected
|
||||||
// output first and use it as our expectation.
|
// output first and use it as our expectation.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user