2
0
mirror of https://github.com/boostorg/hash2.git synced 2026-02-22 15:32:11 +00:00
Files
hash2/test/hash_append_2.cpp
2018-01-06 16:45:24 +02:00

54 lines
957 B
C++

// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
//
// Endian-dependent test
#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/fnv1a.hpp>
#include <boost/core/lightweight_test.hpp>
template<class H, class R> void test( R r )
{
{
int v[4] = { 1, 2, 3, 4 };
H h;
hash_append( h, v[0] );
hash_append( h, v[1] );
hash_append( h, v[2] );
hash_append( h, v[3] );
BOOST_TEST_EQ( h.result(), r );
}
{
int v[4] = { 1, 2, 3, 4 };
H h;
hash_append( h, v );
BOOST_TEST_EQ( h.result(), r );
}
{
int v[2][2] = { { 1, 2 }, { 3, 4 } };
H h;
hash_append( h, v );
BOOST_TEST_EQ( h.result(), r );
}
}
int main()
{
test<boost::hash2::fnv1a_32>( 1041505217ul );
test<boost::hash2::fnv1a_64>( 9566659391000707361ull );
return boost::report_errors();
}