diff options
| author | Nicole Mazzuca <t-nimaz@microsoft.com> | 2019-07-11 18:16:10 -0700 |
|---|---|---|
| committer | Nicole Mazzuca <t-nimaz@microsoft.com> | 2019-07-11 18:21:25 -0700 |
| commit | a0fe40ea5842006c0da901a99ae07d7a25531175 (patch) | |
| tree | 73e7031f04ef399021fe6fe0fd505148d3a5f9a2 /toolsrc/src/tests.strings.cpp | |
| parent | 510b0c5cc0233311b6993b89cd5ce488218ed78d (diff) | |
| download | vcpkg-a0fe40ea5842006c0da901a99ae07d7a25531175.tar.gz vcpkg-a0fe40ea5842006c0da901a99ae07d7a25531175.zip | |
add tests!
Also, fix all the bugs I found when I wrote the tests!
Diffstat (limited to 'toolsrc/src/tests.strings.cpp')
| -rw-r--r-- | toolsrc/src/tests.strings.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/toolsrc/src/tests.strings.cpp b/toolsrc/src/tests.strings.cpp new file mode 100644 index 000000000..14b449e86 --- /dev/null +++ b/toolsrc/src/tests.strings.cpp @@ -0,0 +1,38 @@ +#include "tests.pch.h" + +#include <vcpkg/base/strings.h> + +#include <cstdint> +#include <utility> +#include <vector> + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace UnitTest1 { + class StringsTest : public TestClass<StringsTest> { + TEST_METHOD(b64url_encode) + { + using u64 = std::uint64_t; + + std::vector<std::pair<std::uint64_t, std::string>> map; + + map.emplace_back(0, "AAAAAAAAAAA"); + map.emplace_back(1, "BAAAAAAAAAA"); + + map.emplace_back(u64(1) << 32, "AAAAAEAAAAA"); + map.emplace_back((u64(1) << 32) + 1, "BAAAAEAAAAA"); + + map.emplace_back(0xE4D0'1065'D11E'0229, "pIgHRXGEQTO"); + map.emplace_back(0xA626'FE45'B135'07FF, "_fQNxWk_mYK"); + map.emplace_back(0xEE36'D228'0C31'D405, "FQdMMgi024O"); + map.emplace_back(0x1405'64E7'FE7E'A88C, "Miqf-fOZFQB"); + map.emplace_back(0xFFFF'FFFF'FFFF'FFFF, "__________P"); + + std::string result; + for (const auto& pr : map) { + result = vcpkg::Strings::b64url_encode(pr.first); + Assert::AreEqual(result, pr.second); + } + } + }; +} |
