From 877f6c9342040d6225a0e3b7570597940b8aa702 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 9 Nov 2024 22:00:43 +0200 Subject: [PATCH] Switch Flavor::size_type for the predefined flavors to std::uint64_t; if we at some point need to append a foreign size_t hash, e.g. from std::hash, we need to not throw away information --- include/boost/hash2/flavor.hpp | 6 +++--- test/append_container.cpp | 12 ++++++------ test/append_described_4.cpp | 4 ++-- test/append_map.cpp | 16 ++++++++-------- test/append_set.cpp | 16 ++++++++-------- test/append_string.cpp | 16 ++++++++-------- test/append_string_cx.cpp | 16 ++++++++-------- test/append_string_view.cpp | 16 ++++++++-------- test/append_string_view_cx.cpp | 12 ++++++------ test/append_tag_invoke_2.cpp | 4 ++-- test/append_tag_invoke_3.cpp | 4 ++-- test/append_vector_cx.cpp | 12 ++++++------ test/flavor.cpp | 6 +++--- test/hash_append_5.cpp | 4 ++-- 14 files changed, 72 insertions(+), 72 deletions(-) diff --git a/include/boost/hash2/flavor.hpp b/include/boost/hash2/flavor.hpp index 0e0430a..3d3d20f 100644 --- a/include/boost/hash2/flavor.hpp +++ b/include/boost/hash2/flavor.hpp @@ -15,19 +15,19 @@ namespace hash2 struct default_flavor { - using size_type = std::uint32_t; + using size_type = std::uint64_t; static constexpr auto byte_order = endian::native; }; struct little_endian_flavor { - using size_type = std::uint32_t; + using size_type = std::uint64_t; static constexpr auto byte_order = endian::little; }; struct big_endian_flavor { - using size_type = std::uint32_t; + using size_type = std::uint64_t; static constexpr auto byte_order = endian::big; }; diff --git a/test/append_container.cpp b/test/append_container.cpp index 47c483c..b877b2f 100644 --- a/test/append_container.cpp +++ b/test/append_container.cpp @@ -47,14 +47,14 @@ int main() { using namespace boost::hash2; - test( 2227238665 ); - test( 3245468929 ); + test( 2468847257 ); + test( 78451921 ); - test( 1745310485 ); - test( 3959736277 ); + test( 2374676325 ); + test( 2877134693 ); - test( 1949716516 ); - test( 2651227990 ); + test( 461647460 ); + test( 1394753398 ); return boost::report_errors(); } diff --git a/test/append_described_4.cpp b/test/append_described_4.cpp index 5162261..be79c35 100644 --- a/test/append_described_4.cpp +++ b/test/append_described_4.cpp @@ -67,8 +67,8 @@ int main() { using namespace boost::hash2; - test( {}, 1388033884 ); - test( {}, 3611226160 ); + test( {}, 2447527756 ); + test( {}, 2986383648 ); return boost::report_errors(); } diff --git a/test/append_map.cpp b/test/append_map.cpp index 1c4c735..59e6aca 100644 --- a/test/append_map.cpp +++ b/test/append_map.cpp @@ -65,17 +65,17 @@ int main() { using namespace boost::hash2; - test< fnv1a_32, little_endian_flavor, std::map >( 3152726101ul ); - test< fnv1a_64, little_endian_flavor, std::map >( 11386405661620022965ull ); + test< fnv1a_32, little_endian_flavor, std::map >( 1082144933ul ); + test< fnv1a_64, little_endian_flavor, std::map >( 12051529320333828229ull ); - test< fnv1a_32, little_endian_flavor, std::multimap >( 3152726101ul ); - test< fnv1a_64, little_endian_flavor, std::multimap >( 11386405661620022965ull ); + test< fnv1a_32, little_endian_flavor, std::multimap >( 1082144933ul ); + test< fnv1a_64, little_endian_flavor, std::multimap >( 12051529320333828229ull ); - test< fnv1a_32, little_endian_flavor, std::unordered_map >( 2742410178ul ); - test< fnv1a_64, little_endian_flavor, std::unordered_map >( 7026041901235387186ull ); + test< fnv1a_32, little_endian_flavor, std::unordered_map >( 1094735330ul ); + test< fnv1a_64, little_endian_flavor, std::unordered_map >( 2617313294186790738ull ); - test< fnv1a_32, little_endian_flavor, std::unordered_multimap >( 2742410178ul ); - test< fnv1a_64, little_endian_flavor, std::unordered_multimap >( 7026041901235387186ull ); + test< fnv1a_32, little_endian_flavor, std::unordered_multimap >( 1094735330ul ); + test< fnv1a_64, little_endian_flavor, std::unordered_multimap >( 2617313294186790738ull ); return boost::report_errors(); } diff --git a/test/append_set.cpp b/test/append_set.cpp index 11065be..d5296a2 100644 --- a/test/append_set.cpp +++ b/test/append_set.cpp @@ -63,17 +63,17 @@ int main() { using namespace boost::hash2; - test< fnv1a_32, little_endian_flavor, std::set >( 2078558933ul ); - test< fnv1a_64, little_endian_flavor, std::set >( 6271229243378528309ull ); + test< fnv1a_32, little_endian_flavor, std::set >( 3576652581ul ); + test< fnv1a_64, little_endian_flavor, std::set >( 17046016161958689285ull ); - test< fnv1a_32, little_endian_flavor, std::multiset >( 2078558933ul ); - test< fnv1a_64, little_endian_flavor, std::multiset >( 6271229243378528309ull ); + test< fnv1a_32, little_endian_flavor, std::multiset >( 3576652581ul ); + test< fnv1a_64, little_endian_flavor, std::multiset >( 17046016161958689285ull ); - test< fnv1a_32, little_endian_flavor, std::unordered_set >( 2270492092ul ); - test< fnv1a_64, little_endian_flavor, std::unordered_set >( 2830007867253608057ull ); + test< fnv1a_32, little_endian_flavor, std::unordered_set >( 3782055292ul ); + test< fnv1a_64, little_endian_flavor, std::unordered_set >( 3232503781718511241ull ); - test< fnv1a_32, little_endian_flavor, std::unordered_multiset >( 2270492092ul ); - test< fnv1a_64, little_endian_flavor, std::unordered_multiset >( 2830007867253608057ull ); + test< fnv1a_32, little_endian_flavor, std::unordered_multiset >( 3782055292ul ); + test< fnv1a_64, little_endian_flavor, std::unordered_multiset >( 3232503781718511241ull ); return boost::report_errors(); } diff --git a/test/append_string.cpp b/test/append_string.cpp index 18e39d7..a925100 100644 --- a/test/append_string.cpp +++ b/test/append_string.cpp @@ -42,21 +42,21 @@ int main() { using namespace boost::hash2; - test( 2227238665 ); - test( 3245468929 ); + test( 2468847257 ); + test( 78451921 ); #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L - test( 2227238665 ); - test( 3245468929 ); + test( 2468847257 ); + test( 78451921 ); #endif - test( 2981571797 ); - test( 1063054677 ); + test( 634283301 ); + test( 1469224165 ); - test( 1745310485 ); - test( 3959736277 ); + test( 2374676325 ); + test( 2877134693 ); return boost::report_errors(); } diff --git a/test/append_string_cx.cpp b/test/append_string_cx.cpp index 1235225..bd10a63 100644 --- a/test/append_string_cx.cpp +++ b/test/append_string_cx.cpp @@ -43,21 +43,21 @@ int main() { using namespace boost::hash2; - TEST_EQ( (test()), 2227238665 ); - TEST_EQ( (test()), 3245468929 ); + TEST_EQ( (test()), 2468847257 ); + TEST_EQ( (test()), 78451921 ); #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L - TEST_EQ( (test()), 2227238665 ); - TEST_EQ( (test()), 3245468929 ); + TEST_EQ( (test()), 2468847257 ); + TEST_EQ( (test()), 78451921 ); #endif - TEST_EQ( (test()), 2981571797 ); - TEST_EQ( (test()), 1063054677 ); + TEST_EQ( (test()), 634283301 ); + TEST_EQ( (test()), 1469224165 ); - TEST_EQ( (test()), 1745310485 ); - TEST_EQ( (test()), 3959736277 ); + TEST_EQ( (test()), 2374676325 ); + TEST_EQ( (test()), 2877134693 ); return boost::report_errors(); } diff --git a/test/append_string_view.cpp b/test/append_string_view.cpp index 01e3e08..04b6063 100644 --- a/test/append_string_view.cpp +++ b/test/append_string_view.cpp @@ -54,21 +54,21 @@ int main() { using namespace boost::hash2; - test( 2227238665 ); - test( 3245468929 ); + test( 2468847257 ); + test( 78451921 ); #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L - test( 2227238665 ); - test( 3245468929 ); + test( 2468847257 ); + test( 78451921 ); #endif - test( 2981571797 ); - test( 1063054677 ); + test( 634283301 ); + test( 1469224165 ); - test( 1745310485 ); - test( 3959736277 ); + test( 2374676325 ); + test( 2877134693 ); return boost::report_errors(); } diff --git a/test/append_string_view_cx.cpp b/test/append_string_view_cx.cpp index d5dcf29..64477c2 100644 --- a/test/append_string_view_cx.cpp +++ b/test/append_string_view_cx.cpp @@ -45,16 +45,16 @@ int main() constexpr char const* str = "\x01\x02\x03\x04"; - TEST_EQ( (test( boost::string_view( str, 4 ) )), 2227238665 ); - TEST_EQ( (test( boost::string_view( str, 4 ) )), 3245468929 ); + TEST_EQ( (test( boost::string_view( str, 4 ) )), 2468847257 ); + TEST_EQ( (test( boost::string_view( str, 4 ) )), 78451921 ); - TEST_EQ( (test( boost::core::string_view( str, 4 ) )), 2227238665 ); - TEST_EQ( (test( boost::core::string_view( str, 4 ) )), 3245468929 ); + TEST_EQ( (test( boost::core::string_view( str, 4 ) )), 2468847257 ); + TEST_EQ( (test( boost::core::string_view( str, 4 ) )), 78451921 ); #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) - TEST_EQ( (test( std::string_view( str ) )), 2227238665 ); - TEST_EQ( (test( std::string_view( str ) )), 3245468929 ); + TEST_EQ( (test( std::string_view( str ) )), 2468847257 ); + TEST_EQ( (test( std::string_view( str ) )), 78451921 ); #endif diff --git a/test/append_tag_invoke_2.cpp b/test/append_tag_invoke_2.cpp index c2cff62..6813264 100644 --- a/test/append_tag_invoke_2.cpp +++ b/test/append_tag_invoke_2.cpp @@ -62,8 +62,8 @@ int main() { using namespace boost::hash2; - test( {}, 1388033884 ); - test( {}, 3611226160 ); + test( {}, 2447527756 ); + test( {}, 2986383648 ); return boost::report_errors(); } diff --git a/test/append_tag_invoke_3.cpp b/test/append_tag_invoke_3.cpp index 2e05cb4..7130406 100644 --- a/test/append_tag_invoke_3.cpp +++ b/test/append_tag_invoke_3.cpp @@ -64,8 +64,8 @@ int main() { using namespace boost::hash2; - test( {}, 1388033884 ); - test( {}, 3611226160 ); + test( {}, 2447527756 ); + test( {}, 2986383648 ); return boost::report_errors(); } diff --git a/test/append_vector_cx.cpp b/test/append_vector_cx.cpp index b9236d4..5a25172 100644 --- a/test/append_vector_cx.cpp +++ b/test/append_vector_cx.cpp @@ -43,14 +43,14 @@ int main() { using namespace boost::hash2; - TEST_EQ( (test()), 2227238665 ); - TEST_EQ( (test()), 3245468929 ); + TEST_EQ( (test()), 2468847257 ); + TEST_EQ( (test()), 78451921 ); - TEST_EQ( (test()), 1745310485 ); - TEST_EQ( (test()), 3959736277 ); + TEST_EQ( (test()), 2374676325 ); + TEST_EQ( (test()), 2877134693 ); - TEST_EQ( (test()), 1949716516 ); - TEST_EQ( (test()), 2651227990 ); + TEST_EQ( (test()), 461647460 ); + TEST_EQ( (test()), 1394753398 ); return boost::report_errors(); } diff --git a/test/flavor.cpp b/test/flavor.cpp index 6dc3946..56a8ae0 100644 --- a/test/flavor.cpp +++ b/test/flavor.cpp @@ -11,13 +11,13 @@ int main() { using namespace boost::hash2; - BOOST_TEST_TRAIT_SAME( default_flavor::size_type, std::uint32_t ); + BOOST_TEST_TRAIT_SAME( default_flavor::size_type, std::uint64_t ); BOOST_TEST( default_flavor::byte_order == endian::native ); - BOOST_TEST_TRAIT_SAME( little_endian_flavor::size_type, std::uint32_t ); + BOOST_TEST_TRAIT_SAME( little_endian_flavor::size_type, std::uint64_t ); BOOST_TEST( little_endian_flavor::byte_order == endian::little ); - BOOST_TEST_TRAIT_SAME( big_endian_flavor::size_type, std::uint32_t ); + BOOST_TEST_TRAIT_SAME( big_endian_flavor::size_type, std::uint64_t ); BOOST_TEST( big_endian_flavor::byte_order == endian::big ); return boost::report_errors(); diff --git a/test/hash_append_5.cpp b/test/hash_append_5.cpp index fa2d04e..8fbcff9 100644 --- a/test/hash_append_5.cpp +++ b/test/hash_append_5.cpp @@ -128,8 +128,8 @@ template void test( R r ) int main() { - test( 2425039999ul ); - test( 2425039999ul ); + test( 4058687743ul ); + test( 4058687743ul ); return boost::report_errors(); }