]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/functional/hash/test/hash_sequence_test.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / functional / hash / test / hash_sequence_test.hpp
CommitLineData
7c673cae
FG
1
2// Copyright 2005-2009 Daniel James.
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#if !defined(CONTAINER_TYPE)
7#error "CONTAINER_TYPE not defined"
8#else
9
10#include <boost/preprocessor/cat.hpp>
11
12#if defined(BOOST_MSVC)
13#pragma warning(push)
14#pragma warning(disable:4245) // signed/unsigned mismatch
15#endif
16
17namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
18{
19 template <class T>
20 void integer_tests(T* = 0)
21 {
22 typedef typename T::value_type value_type;
23
24 const int number_of_containers = 11;
25 T containers[number_of_containers];
26
27 for(int i = 0; i < 5; ++i) {
28 for(int j = 0; j < i; ++j)
29 containers[i].push_back(0);
30 }
31
32 containers[5].push_back(value_type(1));
33 containers[6].push_back(value_type(1));
34 containers[6].push_back(value_type(1));
35 containers[7].push_back(value_type(-1));
36 containers[8].push_back(value_type(-1));
37 containers[8].push_back(value_type(-1));
38 containers[9].push_back(value_type(1));
39 containers[9].push_back(value_type(-1));
40 containers[10].push_back(value_type(-1));
41 containers[10].push_back(value_type(1));
42
43 BOOST_HASH_TEST_NAMESPACE::hash<T> hasher;
44
45 for(int i2 = 0; i2 < number_of_containers; ++i2) {
46 BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2]));
47
48 BOOST_TEST(hasher(containers[i2]) ==
49 BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2]));
50
51 BOOST_TEST(hasher(containers[i2])
52 == BOOST_HASH_TEST_NAMESPACE::hash_range(
53 containers[i2].begin(), containers[i2].end()));
54
55 for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
56 BOOST_TEST(
57 (containers[i2] == containers[j2]) ==
58 (hasher(containers[i2]) == hasher(containers[j2]))
59 );
60 }
61 }
62 }
63
64 void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests())
65 {
66 integer_tests((CONTAINER_TYPE<char>*) 0);
67 integer_tests((CONTAINER_TYPE<int>*) 0);
68 integer_tests((CONTAINER_TYPE<unsigned long>*) 0);
69 integer_tests((CONTAINER_TYPE<double>*) 0);
70 }
71}
72
73#if defined(BOOST_MSVC)
74#pragma warning(pop)
75#endif
76
77#undef CONTAINER_TYPE
78#endif