mirror of
https://github.com/boostorg/container_hash.git
synced 2026-02-23 15:42:18 +00:00
@@ -40,6 +40,7 @@ test-suite functional/hash
|
||||
[ run hash_set_test.cpp ]
|
||||
[ run hash_map_test.cpp ]
|
||||
[ run hash_complex_test.cpp ]
|
||||
[ run hash_type_index_test.cpp ]
|
||||
[ run link_test.cpp link_test_2.cpp ]
|
||||
[ run link_ext_test.cpp link_no_ext_test.cpp ]
|
||||
[ run extensions_hpp_test.cpp ]
|
||||
|
||||
48
test/hash_type_index_test.cpp
Normal file
48
test/hash_type_index_test.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
// Copyright 2011 Daniel James.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "./config.hpp"
|
||||
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
void test_type_index() {
|
||||
std::type_index int_index = typeid(int);
|
||||
std::type_index int2_index = typeid(int);
|
||||
std::type_index char_index = typeid(char);
|
||||
|
||||
HASH_NAMESPACE::hash<std::type_index> hasher;
|
||||
|
||||
BOOST_TEST(hasher(int_index) == int_index.hash_code());
|
||||
BOOST_TEST(hasher(int_index) == int2_index.hash_code());
|
||||
BOOST_TEST(hasher(char_index) == char_index.hash_code());
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(int_index) == int_index.hash_code());
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(int_index) == int2_index.hash_code());
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(char_index) == char_index.hash_code());
|
||||
|
||||
BOOST_TEST(hasher(int_index) == hasher(int2_index));
|
||||
BOOST_TEST(hasher(int_index) != hasher(char_index));
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
|
||||
test_type_index();
|
||||
#else
|
||||
std::cout<<"<type_index> not available."<<std::endl;
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user