// 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 #include #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) #include #endif template void test( R r ) { std::basic_string str{ 1, 2, 3, 4 }; Flavor f; { Hash h; boost::hash2::hash_append( h, f, str ); BOOST_TEST_EQ( h.result(), r ); } { Hash h; boost::hash2::hash_append( h, f, boost::basic_string_view( str ) ); BOOST_TEST_EQ( h.result(), r ); } { Hash h; boost::hash2::hash_append( h, f, boost::core::basic_string_view( str ) ); BOOST_TEST_EQ( h.result(), r ); } #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) { Hash h; boost::hash2::hash_append( h, f, std::basic_string_view( str ) ); BOOST_TEST_EQ( h.result(), r ); } #endif } 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(); }