1 //
2 // Copyright (C) 2019 James E. King III
3 //
4 // Permission to copy, use, modify, sell and distribute this software
5 // is granted provided this copyright notice appears in all copies.
6 // This software is provided "as is" without express or implied
7 // warranty, and with no claim as to its suitability for any purpose.
8 //
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12 //
13
14 #include <boost/config.hpp>
15 #include <boost/dynamic_bitset.hpp>
16 #include <boost/core/lightweight_test.hpp>
17 #include <set>
18
main(int,char * [])19 int main(int, char*[])
20 {
21 typedef boost::dynamic_bitset<unsigned long> bitset_type;
22 const std::string long_string =
23 "01001110101110110101011010000000000011110101101111111111";
24 const std::string long_string_prime_begin =
25 "11001110101110110101011010000000000011110101101111111111";
26 const std::string long_string_prime_end =
27 "01001110101110110101011010000000000011110101101111111110";
28
29 bitset_type zeroes(long_string.size(), 0);
30 bitset_type stuff (long_string);
31 bitset_type stupb (long_string_prime_begin);
32 bitset_type stupe (long_string_prime_end);
33 bitset_type ones (long_string.size(), 1);
34
35 boost::hash<bitset_type> bitset_hasher;
36 std::set<std::size_t> results;
37 results.insert(bitset_hasher(zeroes));
38 results.insert(bitset_hasher(stuff));
39 results.insert(bitset_hasher(stupb));
40 results.insert(bitset_hasher(stupe));
41 results.insert(bitset_hasher(ones));
42
43 // if any hash is identical to another there will be less than 5
44 BOOST_TEST_EQ(results.size(), 5);
45
46 return boost::report_errors();
47 }
48