Merge branch 'google:master' into master

This commit is contained in:
Anthony Graca 2021-11-10 21:49:00 -08:00 committed by GitHub
commit 3015953623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 6 deletions

View File

@ -157,8 +157,11 @@ that can be used in the predicate assertion macro
example:
```c++
EXPECT_PRED_FORMAT2(testing::FloatLE, val1, val2);
EXPECT_PRED_FORMAT2(testing::DoubleLE, val1, val2);
using ::testing::FloatLE;
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,
@ -1594,6 +1597,7 @@ void RegisterMyTests(const std::vector<int>& values) {
}
...
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
std::vector<int> values_to_test = LoadValuesFromConfig();
RegisterMyTests(values_to_test);
...

View File

@ -591,6 +591,12 @@ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
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>
void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
UniversalPrinter<T&>::Print(ref.get(), os);

View File

@ -2451,6 +2451,7 @@ GTEST_API_ std::string TempDir();
// }
// ...
// int main(int argc, char** argv) {
// ::testing::InitGoogleTest(&argc, argv);
// std::vector<int> values_to_test = LoadValuesFromConfig();
// RegisterMyTests(values_to_test);
// ...

View File

@ -629,7 +629,8 @@ class ThreadLocalRegistryImpl {
&ThreadLocalRegistryImpl::WatcherThreadFunc,
reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),
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
// blocked by it.
::SetThreadPriority(watcher_thread,

View File

@ -3948,12 +3948,13 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
private:
// Is c a whitespace character that is normalized to a space character
// when it appears in an XML attribute value?
static bool IsNormalizableWhitespace(char c) {
return c == 0x9 || c == 0xA || c == 0xD;
static bool IsNormalizableWhitespace(unsigned char c) {
return c == '\t' || c == '\n' || c == '\r';
}
// 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;
}

View File

@ -473,6 +473,16 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
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
// output differently with different compilers, we have to create the expected
// output first and use it as our expectation.