diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2022-06-05 12:03:08 +0100 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2022-06-05 12:03:09 +0100 |
commit | a13b61f7f0a2a44546fb39663b0d6f2547841e02 (patch) | |
tree | 84bcb51c759ce3b6cc443ddf931ca7216094f2d0 /llvm/unittests/ADT/StringRefTest.cpp | |
parent | 95a134254a403750ddfee7c056efdf2359a7dc8c (diff) | |
download | llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.zip llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.tar.gz llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.tar.bz2 |
[ADT] Add edit_distance_insensitive to StringRef
In some instances its advantageous to calculate edit distances without worrying about casing.
Currently to achieve this both strings need to be converted to the same case first, then edit distance can be calculated.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D126159
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/StringRefTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index e80a25a..ac73458 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -584,6 +584,15 @@ TEST(StringRefTest, EditDistance) { "people soiled our green ")); } +TEST(StringRefTest, EditDistanceInsensitive) { + StringRef Hello("HELLO"); + EXPECT_EQ(2U, Hello.edit_distance_insensitive("hill")); + EXPECT_EQ(0U, Hello.edit_distance_insensitive("hello")); + + StringRef Industry("InDuStRy"); + EXPECT_EQ(6U, Industry.edit_distance_insensitive("iNtErEsT")); +} + TEST(StringRefTest, Misc) { std::string Storage; raw_string_ostream OS(Storage); |