diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-09-27 16:24:37 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-09-27 16:44:49 +0300 |
commit | 3baa8cd76cf09f4359d4e4d0fb0eccd92b04eb23 (patch) | |
tree | 7d2a89a68e4be432122100370b2c207894f49e2a | |
parent | add a std::u16string overload (diff) | |
download | winapi-utf8-3baa8cd76cf09f4359d4e4d0fb0eccd92b04eb23.tar.gz winapi-utf8-3baa8cd76cf09f4359d4e4d0fb0eccd92b04eb23.zip |
test: add a test case for literal values
-rw-r--r-- | test/convert.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/convert.cpp b/test/convert.cpp index 2a113d1..fded6ba 100644 --- a/test/convert.cpp +++ b/test/convert.cpp @@ -46,6 +46,11 @@ std::vector<unsigned char> from(const std::basic_string<CharT>& s) { return {buf, buf + size}; } +template <typename CharT> +std::vector<unsigned char> from(const CharT* s) { + return from(std::basic_string<CharT>{s}); +} + std::vector<std::vector<unsigned char>> utf16 = { // Hello from({0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00}), @@ -76,4 +81,11 @@ BOOST_DATA_TEST_CASE(test_widen, boost::unit_test::data::make(utf8) ^ utf16, inp BOOST_TEST(actual == expected, "Expected: " << expected << ", actual: " << actual); } +BOOST_AUTO_TEST_CASE(test_literals) { + const auto hello16 = u"Привет"; + const auto hello8 = u8"Привет"; + BOOST_TEST(from(hello16) == from(winapi::widen(hello8))); + BOOST_TEST(from(hello8) == from(winapi::narrow(hello16))); +} + BOOST_AUTO_TEST_SUITE_END() |