diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-01 10:31:22 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-01 10:31:22 +0000 |
commit | 1e7804dbd25b8dbf534c850355d70ad215206f4b (patch) | |
tree | dba00119388b84f9f44e6ec5e9129f807fd79ca3 /unittests/ADT/StringRefTest.cpp | |
parent | 571945e6affd20b19264ec22495da418d0fbdbb4 (diff) |
Notes
Diffstat (limited to 'unittests/ADT/StringRefTest.cpp')
-rw-r--r-- | unittests/ADT/StringRefTest.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp index dfa208abefdc..b0dcb0a0abab 100644 --- a/unittests/ADT/StringRefTest.cpp +++ b/unittests/ADT/StringRefTest.cpp @@ -13,7 +13,7 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -namespace { +namespace llvm { std::ostream &operator<<(std::ostream &OS, const StringRef &S) { OS << S; @@ -26,6 +26,9 @@ std::ostream &operator<<(std::ostream &OS, return OS; } +} + +namespace { TEST(StringRefTest, Construction) { EXPECT_EQ("", StringRef()); EXPECT_EQ("hello", StringRef("hello")); @@ -198,6 +201,14 @@ TEST(StringRefTest, StartsWith) { EXPECT_FALSE(Str.startswith("hi")); } +TEST(StringRefTest, EndsWith) { + StringRef Str("hello"); + EXPECT_TRUE(Str.endswith("lo")); + EXPECT_FALSE(Str.endswith("helloworld")); + EXPECT_FALSE(Str.endswith("worldhello")); + EXPECT_FALSE(Str.endswith("so")); +} + TEST(StringRefTest, Find) { StringRef Str("hello"); EXPECT_EQ(2U, Str.find('l')); @@ -236,6 +247,11 @@ TEST(StringRefTest, Count) { EXPECT_EQ(0U, Str.count("zz")); } +TEST(StringRefTest, EditDistance) { + StringRef Str("hello"); + EXPECT_EQ(2U, Str.edit_distance("hill")); +} + TEST(StringRefTest, Misc) { std::string Storage; raw_string_ostream OS(Storage); |