aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/vcpkg-test')
-rw-r--r--toolsrc/src/vcpkg-test/manifests.cpp11
-rw-r--r--toolsrc/src/vcpkg-test/strings.cpp15
2 files changed, 26 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp
index 0d5c9782a..77f4eb440 100644
--- a/toolsrc/src/vcpkg-test/manifests.cpp
+++ b/toolsrc/src/vcpkg-test/manifests.cpp
@@ -248,6 +248,17 @@ TEST_CASE ("SourceParagraph manifest empty supports", "[manifests]")
REQUIRE_FALSE(m_pgh.has_value());
}
+TEST_CASE ("SourceParagraph manifest non-string supports", "[manifests]")
+{
+ auto m_pgh = test_parse_manifest(R"json({
+ "name": "a",
+ "version-string": "1.0",
+ "supports": true
+ })json",
+ true);
+ REQUIRE_FALSE(m_pgh.has_value());
+}
+
TEST_CASE ("Serialize all the ports", "[manifests]")
{
std::vector<std::string> args_list = {"format-manifest"};
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);
+}