summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/test-performance.cpp2
-rw-r--r--src/test-unicode.cpp64
2 files changed, 35 insertions, 31 deletions
diff --git a/src/test-performance.cpp b/src/test-performance.cpp
index 64535c6..90397b7 100644
--- a/src/test-performance.cpp
+++ b/src/test-performance.cpp
@@ -54,7 +54,7 @@ T generate_value(T max = std::numeric_limits<T>::max())
uint32_t value{};
do {
- for (int i = 0; i < sizeof(value); ++i) {
+ for (size_t i = 0; i < sizeof(value); ++i) {
value = (value << 8) | generate_byte();
}
} while (static_cast<uint64_t>(value) >= max_modulo);
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