aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/vcpkg-test/strings.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/strings.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/strings.cpp b/toolsrc/src/vcpkg-test/strings.cpp
index cc45365e6..ecf0524bc 100644
--- a/toolsrc/src/vcpkg-test/strings.cpp
+++ b/toolsrc/src/vcpkg-test/strings.cpp
@@ -56,3 +56,18 @@ TEST_CASE ("find_first_of", "[strings]")
REQUIRE(find_first_of("abcdefg", "bg") == std::string("bcdefg"));
REQUIRE(find_first_of("abcdefg", "gb") == std::string("bcdefg"));
}
+
+TEST_CASE ("edit distance", "[strings]")
+{
+ using vcpkg::Strings::byte_edit_distance;
+ REQUIRE(byte_edit_distance("", "") == 0);
+ REQUIRE(byte_edit_distance("a", "a") == 0);
+ REQUIRE(byte_edit_distance("abcd", "abcd") == 0);
+ REQUIRE(byte_edit_distance("aaa", "aa") == 1);
+ REQUIRE(byte_edit_distance("aa", "aaa") == 1);
+ REQUIRE(byte_edit_distance("abcdef", "bcdefa") == 2);
+ REQUIRE(byte_edit_distance("hello", "world") == 4);
+ REQUIRE(byte_edit_distance("CAPITAL", "capital") == 7);
+ REQUIRE(byte_edit_distance("", "hello") == 5);
+ REQUIRE(byte_edit_distance("world", "") == 5);
+}