// Copyright 2017 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. // // Endian-independent test #include #include #include #include #include #if !defined(BOOST_NO_CXX11_HDR_ARRAY) # include #endif #if !defined(BOOST_NO_CXX11_HDR_TUPLE) # include #endif template void test( R r ) { { unsigned char v[2] = { 1, 2 }; H h; h.update( v, 2 ); BOOST_TEST_EQ( h.result(), r ); } { unsigned char v[2] = { 1, 2 }; H h; hash_append( h, v[0] ); hash_append( h, v[1] ); BOOST_TEST_EQ( h.result(), r ); } { unsigned char v[2] = { 1, 2 }; H h; hash_append( h, v ); BOOST_TEST_EQ( h.result(), r ); } { std::pair v( 1, 2 ); H h; hash_append( h, v ); BOOST_TEST_EQ( h.result(), r ); } { boost::array v = { { 1, 2 } }; H h; hash_append( h, v ); BOOST_TEST_EQ( h.result(), r ); } #if !defined(BOOST_NO_CXX11_HDR_ARRAY) { std::array v = { { 1, 2 } }; H h; hash_append( h, v ); BOOST_TEST_EQ( h.result(), r ); } #endif #if !defined(BOOST_NO_CXX11_HDR_TUPLE) { std::tuple v( 1, 2 ); H h; hash_append( h, v ); BOOST_TEST_EQ( h.result(), r ); } #endif } int main() { test( 3983810698ul ); test( 589729691727335466ull ); return boost::report_errors(); }