1 // Boost.Range library 2 // 3 // Copyright Neil Groves 2014. Use, modification and 4 // distribution is subject to the Boost Software License, Version 5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 // For more information, see http://www.boost.org/libs/range/ 9 // 10 11 #include <boost/range/iterator_range_hash.hpp> 12 13 #include <boost/test/test_tools.hpp> 14 #include <boost/test/unit_test.hpp> 15 16 #include <vector> 17 18 namespace boost_range_test 19 { 20 namespace 21 { 22 test_iterator_range_hash()23void test_iterator_range_hash() 24 { 25 std::vector<boost::int32_t> v; 26 27 for (boost::int32_t i = 0; i < 10; ++i) 28 { 29 v.push_back(i); 30 } 31 32 std::size_t ref_output = boost::hash_range(v.begin(), v.end()); 33 34 boost::iterator_range<std::vector<boost::int32_t>::iterator> rng(v); 35 36 std::size_t test_output = boost::hash_value(rng); 37 38 BOOST_CHECK_EQUAL(ref_output, test_output); 39 } 40 41 } // anonymous namespace 42 } // namespace boost_range_test 43 init_unit_test_suite(int argc,char * argv[])44boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) 45 { 46 boost::unit_test::test_suite* test = 47 BOOST_TEST_SUITE("Boost.Range iterator_range hash function"); 48 49 test->add(BOOST_TEST_CASE(&boost_range_test::test_iterator_range_hash)); 50 51 return test; 52 } 53