diff options
author | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-03-07 16:25:51 (GMT) |
---|---|---|
committer | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-05-29 11:59:42 (GMT) |
commit | eb3953f805d0ed9054dba78b8e842caba0b539c2 (patch) | |
tree | 431b8b25a99617b39a0ba5c8e011e545a6e45865 /googletest/test/googletest-printers-test.cc | |
parent | 843267f0f1482b470fe14201edfda2c64b68232a (diff) | |
download | googletest-eb3953f805d0ed9054dba78b8e842caba0b539c2.zip googletest-eb3953f805d0ed9054dba78b8e842caba0b539c2.tar.gz googletest-eb3953f805d0ed9054dba78b8e842caba0b539c2.tar.bz2 |
make UniversalPrinter<std::any> support RTTIrefs/pull/2742/head
Diffstat (limited to 'googletest/test/googletest-printers-test.cc')
-rw-r--r-- | googletest/test/googletest-printers-test.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 3305035..1324dd6 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -1532,22 +1532,34 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) { } #if GTEST_INTERNAL_HAS_ANY -TEST(PrintAnyTest, Empty) { +class PrintAnyTest : public ::testing::Test { + protected: + template <typename T> + static std::string ExpectedTypeName() { +#if GTEST_HAS_RTTI + return internal::GetTypeName<T>(); +#else + return "the element type"; +#endif // GTEST_HAS_RTTI + } +}; + +TEST_F(PrintAnyTest, Empty) { internal::Any any; EXPECT_EQ("'any' type with no value", PrintToString(any)); } -TEST(PrintAnyTest, NonEmpty) { +TEST_F(PrintAnyTest, NonEmpty) { internal::Any any; constexpr int val1 = 10; const std::string val2 = "content"; any = val1; - EXPECT_EQ("'any' type with value of type the element type", + EXPECT_EQ("'any' type with value of type " + ExpectedTypeName<int>(), PrintToString(any)); any = val2; - EXPECT_EQ("'any' type with value of type the element type", + EXPECT_EQ("'any' type with value of type " + ExpectedTypeName<std::string>(), PrintToString(any)); } #endif // GTEST_INTERNAL_HAS_ANY |