1// Copyright 2021, 2022 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#if defined(__GNUC__) && __GNUC__ == 8
6# pragma GCC diagnostic ignored "-Wsign-conversion"
7#endif
8
9#include <boost/container_hash/hash.hpp>
10#include <boost/core/lightweight_test.hpp>
11#include <vector>
12#include <functional> // to catch msvc-14.1 conflicts
13
14template<class T> void test()
15{
16 typedef std::vector<T> list;
17 typedef boost::hash<list> hash;
18
19 int const N = 32;
20
21 std::size_t h[ N ];
22
23 list v;
24
25 for( int i = 0; i < N; ++i )
26 {
27 h[ i ] = hash()( v );
28
29 BOOST_TEST_EQ( h[ i ], hash()( v ) );
30
31 for( int j = 0; j < i; ++j )
32 {
33 BOOST_TEST_NE( h[ j ], h[ i ] );
34 }
35
36 v.push_back( T() );
37 }
38}
39
40int main()
41{
42 test<int>();
43 test<float>();
44 test<double>();
45 test< std::vector<int> >();
46
47 return boost::report_errors();
48}
49

source code of boost/libs/container_hash/test/hash_vector_test2.cpp