aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/strings.cpp
diff options
context:
space:
mode:
authorBilly O'Neal <bion@microsoft.com>2021-02-04 10:15:44 -0800
committerGitHub <noreply@github.com>2021-02-04 10:15:44 -0800
commitaa60b7efa56a83ead743718941d8b320ef4a05af (patch)
treedb9f9ebd6fa37598b2f5f2ad564eb858cdeddcb0 /toolsrc/src/vcpkg-test/strings.cpp
parentf226416d2eafc495dd03572cb61542fb1670ffdc (diff)
downloadvcpkg-aa60b7efa56a83ead743718941d8b320ef4a05af.tar.gz
vcpkg-aa60b7efa56a83ead743718941d8b320ef4a05af.zip
[vcpkg] Download vcpkg.exe rather than building it in bootstrap on Windows. (#15474)
This reduces bootstrap cost for Windows customers, resolving the issue initially submitted as #12502 . The `toolsrc` tree was extracted to https://github.com/microsoft/vcpkg-tool. `bootstrap.sh` was changed to download the right source tarball, extract, and build it. This was chosen over the previous attempt, a submodule, over concerns of accidentally destroying people's local modifications.
Diffstat (limited to 'toolsrc/src/vcpkg-test/strings.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/strings.cpp114
1 files changed, 0 insertions, 114 deletions
diff --git a/toolsrc/src/vcpkg-test/strings.cpp b/toolsrc/src/vcpkg-test/strings.cpp
deleted file mode 100644
index 32fe5b3af..000000000
--- a/toolsrc/src/vcpkg-test/strings.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/strings.h>
-
-#include <stdint.h>
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#if defined(_MSC_VER)
-#pragma warning(disable : 6237)
-#endif
-
-TEST_CASE ("b32 encoding", "[strings]")
-{
- using u64 = uint64_t;
-
- std::vector<std::pair<u64, std::string>> map;
-
- map.emplace_back(0, "AAAAAAAAAAAAA");
- map.emplace_back(1, "BAAAAAAAAAAAA");
-
- map.emplace_back(u64(1) << 32, "AAAAAAEAAAAAA");
- map.emplace_back((u64(1) << 32) + 1, "BAAAAAEAAAAAA");
-
- map.emplace_back(0xE4D0'1065'D11E'0229, "JRA4RIXMQAUJO");
- map.emplace_back(0xA626'FE45'B135'07FF, "77BKTYWI6XJMK");
- map.emplace_back(0xEE36'D228'0C31'D405, "FAVDDGAFSWN4O");
- map.emplace_back(0x1405'64E7'FE7E'A88C, "MEK5H774ELBIB");
- map.emplace_back(0xFFFF'FFFF'FFFF'FFFF, "777777777777P");
-
- for (const auto& pr : map)
- {
- REQUIRE(vcpkg::Strings::b32_encode(pr.first) == pr.second);
- }
-}
-
-TEST_CASE ("split by char", "[strings]")
-{
- using vcpkg::Strings::split;
- using result_t = std::vector<std::string>;
- REQUIRE(split(",,,,,,", ',').empty());
- REQUIRE(split(",,a,,b,,", ',') == result_t{"a", "b"});
- REQUIRE(split("hello world", ' ') == result_t{"hello", "world"});
- REQUIRE(split(" hello world ", ' ') == result_t{"hello", "world"});
- REQUIRE(split("no delimiters", ',') == result_t{"no delimiters"});
-}
-
-TEST_CASE ("find_first_of", "[strings]")
-{
- using vcpkg::Strings::find_first_of;
- REQUIRE(find_first_of("abcdefg", "hij") == std::string());
- REQUIRE(find_first_of("abcdefg", "a") == std::string("abcdefg"));
- REQUIRE(find_first_of("abcdefg", "g") == std::string("g"));
- 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);
-}
-
-TEST_CASE ("replace_all", "[strings]")
-{
- REQUIRE(vcpkg::Strings::replace_all("literal", "ter", "x") == "lixal");
-}
-
-TEST_CASE ("inplace_replace_all", "[strings]")
-{
- using vcpkg::Strings::inplace_replace_all;
- std::string target;
- inplace_replace_all(target, "", "content");
- REQUIRE(target.empty());
- target = "aa";
- inplace_replace_all(target, "a", "content");
- REQUIRE(target == "contentcontent");
- inplace_replace_all(target, "content", "");
- REQUIRE(target.empty());
- target = "ababababa";
- inplace_replace_all(target, "aba", "X");
- REQUIRE(target == "XbXba");
- target = "ababababa";
- inplace_replace_all(target, "aba", "aba");
- REQUIRE(target == "ababababa");
-}
-
-TEST_CASE ("inplace_replace_all(char)", "[strings]")
-{
- using vcpkg::Strings::inplace_replace_all;
- static_assert(noexcept(inplace_replace_all(std::declval<std::string&>(), 'a', 'a')));
-
- std::string target;
- inplace_replace_all(target, ' ', '?');
- REQUIRE(target.empty());
- target = "hello";
- inplace_replace_all(target, 'l', 'w');
- REQUIRE(target == "hewwo");
- inplace_replace_all(target, 'w', 'w');
- REQUIRE(target == "hewwo");
- inplace_replace_all(target, 'x', '?');
- REQUIRE(target == "hewwo");
-}