// Copyright 2017, 2024 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include #include #include #include template void test_container( R r ) { unsigned char w[] = { 1, 2, 3, 4 }; T v( w, w + sizeof(w) / sizeof(w[0]) ); Flavor f; { Hash h; boost::hash2::hash_append( h, f, v ); BOOST_TEST_EQ( h.result(), r ); } { Hash h; boost::hash2::hash_append_range_and_size( h, f, v.begin(), v.end() ); BOOST_TEST_EQ( h.result(), r ); } } template void test( R r ) { test_container< Hash, Flavor, std::basic_string >( r ); test_container< Hash, Flavor, std::vector >( r ); test_container< Hash, Flavor, std::list >( r ); } int main() { using namespace boost::hash2; test( 2227238665 ); test( 3245468929 ); #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L test( 2227238665 ); test( 3245468929 ); #endif test( 2981571797 ); test( 1063054677 ); test( 1745310485 ); test( 3959736277 ); return boost::report_errors(); }