Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / array / test / array_hash.cpp
1 /* tests for using boost::hash with boost::array
2  * (C) Copyright Marshall Clow 2012
3  * Distributed under the Boost Software License, Version 1.0. (See
4  * accompanying file LICENSE_1_0.txt or copy at
5  * http://www.boost.org/LICENSE_1_0.txt)
6  */
7
8 #include <string>
9 #include <iostream>
10 #include <boost/array.hpp>
11 #include <algorithm>
12 #include <boost/functional/hash.hpp>
13
14 #define BOOST_TEST_MAIN
15 #include <boost/test/unit_test.hpp>
16
17 namespace {
18
19     template< class T >
20     void    RunTests()
21     {
22     //    std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
23     //    std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
24     
25         typedef boost::array< T, 5 >    barr;
26         typedef T arr[5];
27         barr           test_barr =   {{ 1, 1, 2, 3, 5 }};
28         arr            test_arr  =    { 1, 1, 2, 3, 5 };
29     
30         std::size_t bhash = boost::hash<barr> () ( test_barr );
31         std::size_t ahash = boost::hash<arr>  () ( test_arr );
32         BOOST_CHECK ( ahash == bhash );
33     }
34
35 }
36
37 BOOST_AUTO_TEST_CASE( test_main )
38 {
39     RunTests< int >();
40     RunTests< long >();
41     RunTests< long double >();
42 }
43