summaryrefslogtreecommitdiffhomepage
path: root/src/test-unicode.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-12-06 16:31:02 +0100
committerRoland Reichwein <mail@reichwein.it>2021-12-06 16:31:02 +0100
commit955b3b84dd2dadd539dbc707c26c33ad3e63b374 (patch)
treee87107a2233bef7aac37438c39923366e9099f5e /src/test-unicode.cpp
parentf61b0aeafd2f5f2619ff21efb000026364c79230 (diff)
Fixes for new compiler versions
Diffstat (limited to 'src/test-unicode.cpp')
-rw-r--r--src/test-unicode.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/test-unicode.cpp b/src/test-unicode.cpp
index b5b48f0..ef68e02 100644
--- a/src/test-unicode.cpp
+++ b/src/test-unicode.cpp
@@ -39,11 +39,19 @@ std::vector<types_collection_type> success_sets {
// Error cases: throwing upon convert to all other types
std::vector<std::basic_string<utf8_t>> failure_strings_char8_t {
// using u8"" here doesn't work on MSVC
- u8"\x80", // utf-8 continuation byte
- u8"\x81", // utf-8 continuation byte
- u8"\xc3\xc3\xa4", // initial byte of utf-8 "ä", followed by valid utf-8 "ä"
- u8"\xF8\x80\x80\x80\x80", // overlong encoding
- u8"\xF7\xBF\xBF\xBF", // valid encoding of invalid code point
+#if (__cplusplus >= 202002L)
+ (char8_t*)"\x80", // utf-8 continuation byte
+ (char8_t*)"\x81", // utf-8 continuation byte
+ (char8_t*)"\xc3\xc3\xa4", // initial byte of utf-8 "ä", followed by valid utf-8 "ä"
+ (char8_t*)"\xF8\x80\x80\x80\x80", // overlong encoding
+ (char8_t*)"\xF7\xBF\xBF\xBF", // valid encoding of invalid code point
+#else
+ "\x80", // utf-8 continuation byte
+ "\x81", // utf-8 continuation byte
+ "\xc3\xc3\xa4", // initial byte of utf-8 "ä", followed by valid utf-8 "ä"
+ "\xF8\x80\x80\x80\x80", // overlong encoding
+ "\xF7\xBF\xBF\xBF", // valid encoding of invalid code point
+#endif
};
std::vector<std::basic_string<char16_t>> failure_strings_char16_t {
@@ -350,6 +358,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(random_sequences, T, types_collection_type)
}
BOOST_CHECK_MESSAGE(i > 1, "Not enough iterations done!");
+
+ std::cout << "random_sequences: Completed " << i << " iterations for long random code unit sequences for " << typeid(typename T::value_type).name() << std::endl;
}
// Test ISO and UTF encodings
@@ -385,8 +395,12 @@ BOOST_AUTO_TEST_CASE(convert)
BOOST_CHECK((unicode::convert<char, wchar_t>("\u732b")) == std::wstring{L"\u732b"});
BOOST_CHECK((unicode::convert<char, wchar_t>("\U0001F63A")) == std::wstring{L"\U0001F63A"});
BOOST_CHECK((unicode::convert<wchar_t, char32_t>(L"\U0001F63A")) == std::u32string{U"\U0001F63A"});
+#if (__cplusplus >= 202002L)
BOOST_CHECK((unicode::convert<wchar_t, utf8_t>(L"\U0001F63A")) == std::u8string{u8"\U0001F63A"});
-
+#else
+ BOOST_CHECK((unicode::convert<wchar_t, utf8_t>(L"\U0001F63A")) == std::string{"\U0001F63A"});
+#endif
+
BOOST_CHECK((unicode::convert<std::string, std::wstring>(std::string{"äöü"})) == std::wstring{L"äöü"});
BOOST_CHECK((unicode::convert<std::vector<char>, std::vector<wchar_t>>(std::vector<char>{})) == std::vector<wchar_t>{});