summaryrefslogtreecommitdiffhomepage
path: root/src/test-unicode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test-unicode.cpp')
-rw-r--r--src/test-unicode.cpp64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/test-unicode.cpp b/src/test-unicode.cpp
index aebc644..948dbcc 100644
--- a/src/test-unicode.cpp
+++ b/src/test-unicode.cpp
@@ -681,7 +681,7 @@ BOOST_AUTO_TEST_CASE(exceptions)
{ // UTF-32: Invalid value
std::vector<char32_t> x{(char32_t)U'\xFFFFFFFF'};
try {
- auto result{unicode::convert<std::vector<char32_t>,std::vector<char8_t>>(x)};
+ auto result{unicode::convert<std::vector<char32_t>,std::vector<utf8_t>>(x)};
BOOST_FAIL("Expected boost convert to fail");
} catch (const std::invalid_argument& ex) {
BOOST_CHECK_EQUAL("Invalid Unicode character: 4294967295"s, ex.what());
@@ -751,40 +751,44 @@ BOOST_AUTO_TEST_CASE(exceptions)
}
#if defined(_WIN32) || defined(__linux__)
- { // Optimization: UTF-8 decoding invalid Unicode value in 3 byte sequence
- std::basic_string<utf8_t> x{(utf8_t*)"\xED\xA0\x80 aaa"};
- try {
- auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
- BOOST_FAIL("Expected boost convert to fail");
- } catch (const std::invalid_argument& ex) {
- BOOST_CHECK_EQUAL("Invalid Unicode character in 3 byte UTF-8 sequence"s, ex.what());
- } catch (...) {
- BOOST_ERROR("Unexpected error on convert");
+ if constexpr (sizeof(size_t) == 8) {
+
+ { // Optimization: UTF-8 decoding invalid Unicode value in 3 byte sequence
+ std::basic_string<utf8_t> x{(utf8_t*)"\xED\xA0\x80 aaa"};
+ try {
+ auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
+ BOOST_FAIL("Expected boost convert to fail");
+ } catch (const std::invalid_argument& ex) {
+ BOOST_CHECK_EQUAL("Invalid Unicode character in 3 byte UTF-8 sequence"s, ex.what());
+ } catch (...) {
+ BOOST_ERROR("Unexpected error on convert");
+ }
}
- }
- { // Optimization: UTF-8 decoding invalid Unicode value in 4 byte sequence
- std::basic_string<utf8_t> x{(utf8_t*)"\xF7\xBF\xBF\xBF aaa"};
- try {
- auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
- BOOST_FAIL("Expected boost convert to fail");
- } catch (const std::invalid_argument& ex) {
- BOOST_CHECK_EQUAL("Invalid Unicode character in 4 byte UTF-8 sequence"s, ex.what());
- } catch (...) {
- BOOST_ERROR("Unexpected error on convert");
+ { // Optimization: UTF-8 decoding invalid Unicode value in 4 byte sequence
+ std::basic_string<utf8_t> x{(utf8_t*)"\xF7\xBF\xBF\xBF aaa"};
+ try {
+ auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
+ BOOST_FAIL("Expected boost convert to fail");
+ } catch (const std::invalid_argument& ex) {
+ BOOST_CHECK_EQUAL("Invalid Unicode character in 4 byte UTF-8 sequence"s, ex.what());
+ } catch (...) {
+ BOOST_ERROR("Unexpected error on convert");
+ }
}
- }
- { // Optimization: UTF-8 decoding invalid byte sequence
- std::basic_string<utf8_t> x{(utf8_t*)"\xC0 aabbbb"};
- try {
- auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
- BOOST_FAIL("Expected boost convert to fail");
- } catch (const std::invalid_argument& ex) {
- BOOST_CHECK_EQUAL("Invalid UTF-8 byte sequence"s, ex.what());
- } catch (...) {
- BOOST_ERROR("Unexpected error on convert");
+ { // Optimization: UTF-8 decoding invalid byte sequence
+ std::basic_string<utf8_t> x{(utf8_t*)"\xC0 aabbbb"};
+ try {
+ auto result{unicode::convert<unicode::UTF_8,unicode::UTF_16>(x)};
+ BOOST_FAIL("Expected boost convert to fail");
+ } catch (const std::invalid_argument& ex) {
+ BOOST_CHECK_EQUAL("Invalid UTF-8 byte sequence"s, ex.what());
+ } catch (...) {
+ BOOST_ERROR("Unexpected error on convert");
+ }
}
+
}
#endif