summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/SmallStringTest.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-08-21 13:56:29 +0000
committerSam McCall <sam.mccall@gmail.com>2019-08-21 13:56:29 +0000
commita451156bb6ceb3700f6ea42e47e9a95d67723318 (patch)
tree4227645ea627fffc6f82efaaec49e7573e954211 /llvm/unittests/ADT/SmallStringTest.cpp
parent4d668a1f077d1ddea6130c52f793817063046b68 (diff)
downloadbcm5719-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/ADT/SmallStringTest.cpp')
-rw-r--r--llvm/unittests/ADT/SmallStringTest.cpp10
1 files changed, 9 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
OpenPOWER on IntegriCloud