• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2014 Christoph Weiss
3     Copyright (c) 2017 Kohei Takahashi
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #include <string>
9 #include <utility>
10 
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/fusion/sequence/hash.hpp>
13 #include <boost/functional/hash.hpp>
14 
hash_test()15 void hash_test()
16 {
17     namespace fusion = boost::fusion;
18     using namespace fusion;
19 
20     const FUSION_SEQUENCE<int, char, bool, std::string> v0(42, 'x', false, "Aurea prima");
21     const FUSION_SEQUENCE<int, char, bool, std::string> v1(42, 'x', false, "Aurea prima");
22     BOOST_TEST(fusion::hash_value(v0) == fusion::hash_value(v1));
23 
24     const FUSION_SEQUENCE<int, char, bool, std::string> w(41, 'x', false, "Aurea prima");
25     BOOST_TEST(fusion::hash_value(w) != fusion::hash_value(v0));
26 
27     const FUSION_SEQUENCE<int, char, bool, std::string> x(42, 'y', false, "Aurea prima");
28     BOOST_TEST(fusion::hash_value(x) != fusion::hash_value(v0));
29 
30     const FUSION_SEQUENCE<int, char, bool, std::string> y(42, 'x', true, "Aurea prima");
31     BOOST_TEST(fusion::hash_value(y) != fusion::hash_value(v0));
32 
33     const FUSION_SEQUENCE<int, char, bool, std::string> z(42, 'x', false, "quae vindice nullo");
34     BOOST_TEST(fusion::hash_value(z) != fusion::hash_value(v0));
35 }
36