From 3baa8cd76cf09f4359d4e4d0fb0eccd92b04eb23 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 27 Sep 2021 16:24:37 +0300 Subject: test: add a test case for literal values --- test/convert.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/convert.cpp') 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 from(const std::basic_string& s) { return {buf, buf + size}; } +template +std::vector from(const CharT* s) { + return from(std::basic_string{s}); +} + std::vector> 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() -- cgit v1.2.3