From: Sam McCall Date: Wed, 21 Aug 2019 13:31:44 +0000 (+0000) Subject: Revert "[gtest] Fix printing of StringRef and SmallString in assert messages." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a26ebc893ce2db7d551825ed595a5cacc9eb3f98;p=llvm Revert "[gtest] Fix printing of StringRef and SmallString in assert messages." This reverts commit 4becb2ab4e9f52ce98272d1f5930d6942af5172b. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369525 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/ADT/SmallStringTest.cpp b/unittests/ADT/SmallStringTest.cpp index 686215fd223..6868381c5cf 100644 --- a/unittests/ADT/SmallStringTest.cpp +++ b/unittests/ADT/SmallStringTest.cpp @@ -169,7 +169,7 @@ TEST_F(SmallStringTest, Realloc) { EXPECT_EQ("abcdyyy", theString.slice(0, 7)); } -TEST_F(SmallStringTest, Comparisons) { +TEST(StringRefTest, Comparisons) { EXPECT_EQ(-1, SmallString<10>("aab").compare("aad")); EXPECT_EQ( 0, SmallString<10>("aab").compare("aab")); EXPECT_EQ( 1, SmallString<10>("aab").compare("aaa")); @@ -203,12 +203,4 @@ TEST_F(SmallStringTest, Comparisons) { EXPECT_EQ( 1, SmallString<10>("V8_q0").compare_numeric("V1_q0")); } -// Check gtest prints SmallString as a string instead of a container of chars. -// The code is in utils/unittest/googletest/internal/custom/gtest-printers.h -TEST_F(SmallStringTest, GTestPrinter) { - EXPECT_EQ(R"("foo")", ::testing::PrintToString(SmallString<1>("foo"))); - const SmallVectorImpl &ErasedSmallString = SmallString<1>("foo"); - EXPECT_EQ(R"("foo")", ::testing::PrintToString(ErasedSmallString)); } - -} // namespace diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp index f341cf402a0..a45e83c1163 100644 --- a/unittests/ADT/StringRefTest.cpp +++ b/unittests/ADT/StringRefTest.cpp @@ -1055,12 +1055,6 @@ TEST(StringRefTest, StringLiteral) { EXPECT_EQ(StringRef("Bar"), Strings[1]); } -// Check gtest prints StringRef as a string instead of a container of chars. -// The code is in utils/unittest/googletest/internal/custom/gtest-printers.h -TEST(StringRefTest, GTestPrinter) { - EXPECT_EQ(R"("foo")", ::testing::PrintToString(StringRef("foo"))); -} - static_assert(is_trivially_copyable::value, "trivially copyable"); } // end anonymous namespace diff --git a/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h b/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h index da2b418525c..60c1ea050b6 100644 --- a/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h +++ b/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h @@ -39,33 +39,4 @@ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringRef.h" -#include - -namespace llvm { - -// Printing of llvm String types. -// gtest sees these as containers of char (they have nested iterator types), -// so their operator<< is never considered unless we provide PrintTo(). -// PrintStringTo provides quotes and escaping, at the cost of a copy. - -inline void PrintTo(llvm::StringRef S, std::ostream *OS) { - *OS << ::testing::PrintToString(S.str()); -} -// We need both SmallString and SmallVectorImpl overloads: -// - the SmallString template is needed as overload resolution will -// instantiate generic PrintTo rather than do derived-to-base conversion -// - but SmallVectorImpl is sometimes the actual static type, in code -// that erases the small size -template -inline void PrintTo(const SmallString &S, std::ostream *OS) { - *OS << ::testing::PrintToString(std::string(S.data(), S.size())); -} -inline void PrintTo(const SmallVectorImpl &S, std::ostream *OS) { - *OS << ::testing::PrintToString(std::string(S.data(), S.size())); -} - -} // namespace llvm - #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_