diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-08-21 13:56:29 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-08-21 13:56:29 +0000 |
| commit | a451156bb6ceb3700f6ea42e47e9a95d67723318 (patch) | |
| tree | 4227645ea627fffc6f82efaaec49e7573e954211 /llvm/unittests | |
| parent | 4d668a1f077d1ddea6130c52f793817063046b68 (diff) | |
| download | bcm5719-llvm-a451156bb6ceb3700f6ea42e47e9a95d67723318.tar.gz bcm5719-llvm-a451156bb6ceb3700f6ea42e47e9a95d67723318.zip | |
reland [gtest] Fix printing of StringRef and SmallString in assert messages.
Renames GTEST_NO_LLVM_RAW_OSTREAM -> GTEST_NO_LLVM_SUPPORT and guards
the new features behind it.
This reverts commit a063bcf3ef5a879adbe9639a3c187d876eee0e66.
llvm-svn: 369527
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/ADT/SmallStringTest.cpp | 10 | ||||
| -rw-r--r-- | llvm/unittests/ADT/StringRefTest.cpp | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp index 6868381c5cf..686215fd223 100644 --- a/llvm/unittests/ADT/SmallStringTest.cpp +++ b/llvm/unittests/ADT/SmallStringTest.cpp @@ -169,7 +169,7 @@ TEST_F(SmallStringTest, Realloc) { EXPECT_EQ("abcdyyy", theString.slice(0, 7)); } -TEST(StringRefTest, Comparisons) { +TEST_F(SmallStringTest, 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,4 +203,12 @@ TEST(StringRefTest, 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<char> &ErasedSmallString = SmallString<1>("foo"); + EXPECT_EQ(R"("foo")", ::testing::PrintToString(ErasedSmallString)); } + +} // namespace diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index a45e83c1163..f341cf402a0 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -1055,6 +1055,12 @@ 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<StringRef>::value, "trivially copyable"); } // end anonymous namespace |

