diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test-performance.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test-performance.cpp b/src/test-performance.cpp index 90397b7..26ae5d2 100644 --- a/src/test-performance.cpp +++ b/src/test-performance.cpp @@ -50,7 +50,9 @@ uint8_t generate_byte() template<typename T> T generate_value(T max = std::numeric_limits<T>::max()) { - uint64_t max_modulo{ static_cast<uint64_t>(0x100000000ULL) - (0x100000000ULL % (max + 1))}; + BOOST_REQUIRE_LE(max, 0xFFFFFFFFFFFFFFFF); + + uint64_t max_modulo{ static_cast<uint64_t>(0x100000000ULL) - (0x100000000ULL % (static_cast<uint64_t>(max) + 1))}; uint32_t value{}; do { @@ -59,7 +61,7 @@ T generate_value(T max = std::numeric_limits<T>::max()) } } while (static_cast<uint64_t>(value) >= max_modulo); - return static_cast<T>(value % (max + 1)); + return static_cast<T>(value % (static_cast<uint64_t>(max) + 1)); } // generates valid and invalid strings of different type @@ -91,7 +93,6 @@ std::u32string generate_string(char32_t max, size_t length) template<typename From, typename ToTypesCollectionType, size_t i = 0> void test_string_invalid(size_t length) { - //std::cerr << "LENGTH: " << length << std::endl; typedef typename std::tuple_element<i,ToTypesCollectionType>::type To; From r {static_cast<From>(generate_string_invalid<From>(length))}; @@ -196,6 +197,7 @@ void test_string_valid(char32_t max, size_t length, const std::string& descripti return unicode::convert<unicode::UTF_32, typename unicode::Encoding_t<typename From::value_type>>(s); }); + // Sanity check before performance tests for (size_t i = 0; i < list.size(); i++) { BOOST_CHECK(list[i].size() >= u32list[i].size()); To result{unicode::convert<typename unicode::Encoding_t<typename From::value_type>,typename unicode::Encoding_t<typename To::value_type>>(list[i])}; |