From 2d557a746dbcd95abaf74a56c9fb77aa7b663c92 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 16 Jul 2022 11:16:06 +0300 Subject: [PATCH] Add hash_vector_test2.cpp --- test/Jamfile.v2 | 2 ++ test/hash_vector_test2.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/hash_vector_test2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f0d7001..8ce0b34 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -81,3 +81,5 @@ run hash_fs_path_test.cpp /boost//filesystem/off : : : $(fs-path-req) run detail_is_range_test2.cpp : : : $(fs-path-req) ; run hash_container_test.cpp ; + +run hash_vector_test2.cpp ; diff --git a/test/hash_vector_test2.cpp b/test/hash_vector_test2.cpp new file mode 100644 index 0000000..c33d1d0 --- /dev/null +++ b/test/hash_vector_test2.cpp @@ -0,0 +1,48 @@ +// Copyright 2021, 2022 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(__GNUC__) && __GNUC__ == 8 +# pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +#include +#include +#include +#include // to catch msvc-14.1 conflicts + +template void test() +{ + typedef std::vector list; + typedef boost::hash hash; + + int const N = 32; + + std::size_t h[ N ]; + + list v; + + for( int i = 0; i < N; ++i ) + { + h[ i ] = hash()( v ); + + BOOST_TEST_EQ( h[ i ], hash()( v ) ); + + for( int j = 0; j < i; ++j ) + { + BOOST_TEST_NE( h[ j ], h[ i ] ); + } + + v.push_back( T() ); + } +} + +int main() +{ + test(); + test(); + test(); + test< std::vector >(); + + return boost::report_errors(); +}