aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/strings.cpp
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-10-12 10:22:47 -0700
committerGitHub <noreply@github.com>2020-10-12 10:22:47 -0700
commitd1ba685e975db41d767af5676ca2669a5e7e6ad9 (patch)
treee6dcb36f131e638fd5307a304a8fb5f2ce072758 /toolsrc/src/vcpkg-test/strings.cpp
parentd6b5fbfef10e9476cdb8d1a90503f4f6504e63d9 (diff)
downloadvcpkg-d1ba685e975db41d767af5676ca2669a5e7e6ad9.tar.gz
vcpkg-d1ba685e975db41d767af5676ca2669a5e7e6ad9.zip
[vcpkg] Further JSON error improvements (#13399)
* [vcpkg] Split vcpkg/base/json.h into vcpkg/base/jsonreader.h * [vcpkg] Extract definitions of Configuration-Deserializer (& friends) These types are only used by VcpkgPaths during the initial parse. * [vcpkg] Introduce levenshtein-distance suggestions for json errors * [vcpkg] Fix regression in supports handling * [vcpkg] Fix signed/unsigned mismatch * [vcpkg] Address CR comments * [vcpkg] Address CR comments * Fix compiler error from merge conflict. * [vcpkg] Change parameters of Reader::check_for_unexpected_fields to better match declaration * [vcpkg] Improve errors from features set * [vcpkg] Fix includes * [vcpkg] Reuse code * [vcpkg] Check the "name" field always to maximize error information * [docs] Improve english phrasing in manifests.md * [vcpkg] Correct docs link for manifests Co-authored-by: Robert Schumacher <roschuma@microsoft.com> Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
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);
+}