From 1ad79db10ebf22c817e09127b64ad685456a093e Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Fri, 14 Apr 2017 08:34:32 +0000 Subject: [PATCH] Add more test cases for StringRef::edit_distance Example strings taken from here: http://www.let.rug.nl/~kleiweg/lev/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300312 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/StringRefTest.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp index bd9387837df..e308f2d7c64 100644 --- a/unittests/ADT/StringRefTest.cpp +++ b/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) { -- 2.40.0