summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-02-12 18:12:51 +0100
committerRoland Reichwein <mail@reichwein.it>2021-02-12 18:12:51 +0100
commit24ec1d5ba85503599fd301aa8cd56ee65651ab0b (patch)
treeccabf3b89338825720e926a73602862df03ae801 /src
parentb47110d30db3a416775c5de88e1d946dfdbda734 (diff)
Added support for char and wchar_t
Diffstat (limited to 'src')
-rw-r--r--src/test-unicode.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test-unicode.cpp b/src/test-unicode.cpp
index 692dfac..99a8f99 100644
--- a/src/test-unicode.cpp
+++ b/src/test-unicode.cpp
@@ -334,6 +334,23 @@ BOOST_AUTO_TEST_CASE(convert)
BOOST_CHECK((unicode::convert<utf8_t,char16_t>("abc")) == std::u16string{u"abc"});
BOOST_CHECK((unicode::convert<char32_t,char16_t>(U"abc")) == std::u16string{u"abc"});
+
+ BOOST_CHECK((unicode::convert<char, char32_t>(u8"äöü")) == std::u32string{U"äöü"});
+
+#ifdef _WIN32
+ BOOST_CHECK(sizeof(wchar_t) == 2);
+#else // Unix like
+ BOOST_CHECK(sizeof(wchar_t) == 4);
+#endif
+
+ // For the following checks, wchar_t size and encoding is system dependent:
+ // Windows: UTF-16
+ // Linux: UTF-32
+ BOOST_CHECK((unicode::convert<char, wchar_t>(u8"äöü")) == std::wstring{L"äöü"});
+ BOOST_CHECK((unicode::convert<char, wchar_t>(u8"\u732b")) == std::wstring{L"\u732b"});
+ BOOST_CHECK((unicode::convert<char, wchar_t>(u8"\U0001F63A")) == std::wstring{L"\U0001F63A"});
+ BOOST_CHECK((unicode::convert<wchar_t, char32_t>(L"\U0001F63A")) == std::u32string{U"\U0001F63A"});
+ BOOST_CHECK((unicode::convert<wchar_t, char>(L"\U0001F63A")) == std::string{u8"\U0001F63A"});
}
BOOST_AUTO_TEST_CASE(is_valid_utf)