1 // Copyright (c) 2011-2014
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 #include "boost/test/minimal.hpp"
9 #include "boost/variant.hpp"
10 #include "boost/functional/hash/hash.hpp"
14 typedef boost::variant<bool, int, unsigned int, char> variant_type;
15 boost::hash<variant_type> hasher;
17 variant_type bool_variant1 = true;
18 variant_type bool_variant2 = false;
19 variant_type int_variant = 1;
20 variant_type char_variant1 = '\1';
21 variant_type char_variant2 = '\2';
22 variant_type uint_variant = static_cast<unsigned int>(1);
24 BOOST_CHECK(hasher(bool_variant1) != hasher(bool_variant2));
25 BOOST_CHECK(hasher(bool_variant1) == hasher(bool_variant1));
26 BOOST_CHECK(hasher(int_variant) != hasher(uint_variant));
27 BOOST_CHECK(hasher(char_variant1) != hasher(uint_variant));
28 BOOST_CHECK(hasher(char_variant1) != hasher(char_variant2));
29 BOOST_CHECK(hasher(char_variant1) == hasher(char_variant1));
30 BOOST_CHECK(hasher(char_variant2) == hasher(char_variant2));
33 int test_main(int , char* [])