aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorAlex Denisov <1101.debian@gmail.com>2017-04-14 08:34:32 +0000
committerAlex Denisov <1101.debian@gmail.com>2017-04-14 08:34:32 +0000
commit3aa1d004b6b72dac6e8d3b0d36bf1b0c375ce4a5 (patch)
tree06bde551d39795ac70fbce93a9343659fbe6eee2 /llvm/unittests/ADT/StringRefTest.cpp
parent75745d0c3e612b54af6b1cfb62be69356ad155a2 (diff)
downloadllvm-3aa1d004b6b72dac6e8d3b0d36bf1b0c375ce4a5.zip
llvm-3aa1d004b6b72dac6e8d3b0d36bf1b0c375ce4a5.tar.gz
llvm-3aa1d004b6b72dac6e8d3b0d36bf1b0c375ce4a5.tar.bz2
Add more test cases for StringRef::edit_distance
Example strings taken from here: http://www.let.rug.nl/~kleiweg/lev/ llvm-svn: 300312
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index bd93878..e308f2d 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -504,8 +504,22 @@ TEST(StringRefTest, Count) {
}
TEST(StringRefTest, EditDistance) {
- StringRef Str("hello");
- EXPECT_EQ(2U, Str.edit_distance("hill"));
+ StringRef Hello("hello");
+ EXPECT_EQ(2U, Hello.edit_distance("hill"));
+
+ StringRef Industry("industry");
+ EXPECT_EQ(6U, Industry.edit_distance("interest"));
+
+ StringRef Soylent("soylent green is people");
+ EXPECT_EQ(19U, Soylent.edit_distance("people soiled our green"));
+ EXPECT_EQ(26U, Soylent.edit_distance("people soiled our green",
+ /* allow replacements = */ false));
+ EXPECT_EQ(9U, Soylent.edit_distance("people soiled our green",
+ /* allow replacements = */ true,
+ /* max edit distance = */ 8));
+ EXPECT_EQ(53U, Soylent.edit_distance("people soiled our green "
+ "people soiled our green "
+ "people soiled our green "));
}
TEST(StringRefTest, Misc) {