Add the boost::hash unit tests.

[SVN r27903]
This commit is contained in:
Daniel James
2005-04-01 16:58:09 +00:00
parent 2b375867f5
commit 8bfc36b94d
17 changed files with 697 additions and 0 deletions

41
test/Jamfile Normal file
View File

@@ -0,0 +1,41 @@
# (C) Copyright Daniel James 2005.
# Use, modification and distribution are subject to 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)
subproject libs/functional/hash/test ;
import testing ;
DEPENDS all : hash_std hash_extensions ;
rule hash-test ( name )
{
return [
run $(name).cpp
<lib>../../../test/build/boost_unit_test_framework
: : : <include>$(BOOST_ROOT)
] ;
}
{
test-suite "hash_std"
:
[ hash-test hash_number_test ]
[ hash-test hash_pointer_test ]
[ hash-test hash_float_test ]
[ hash-test hash_string_test ]
;
test-suite "hash_extensions"
:
[ hash-test hash_range_test ]
[ hash-test hash_custom_test ]
[ hash-test hash_vector_test ]
[ hash-test hash_list_test ]
[ hash-test hash_deque_test ]
[ hash-test hash_set_test ]
[ hash-test hash_map_test ]
;
}

28
test/Jamfile.v2 Normal file
View File

@@ -0,0 +1,28 @@
# (C) Copyright Daniel James 2005.
# Use, modification and distribution are subject to 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)
import testing ;
alias framework : /boost/test//boost_unit_test_framework ;
test-suite /boost/hash_std
:
[ run hash_number_test.cpp framework ]
[ run hash_pointer_test.cpp framework ]
[ run hash_float_test.cpp framework ]
[ run hash_string_test.cpp framework ]
;
test-suite /boost/hash_extensions
:
[ run hash_range_test.cpp framework ]
[ run hash_custom_test.cpp framework ]
[ run hash_vector_test.cpp framework ]
[ run hash_list_test.cpp framework ]
[ run hash_deque_test.cpp framework ]
[ run hash_set_test.cpp framework ]
[ run hash_map_test.cpp framework ]
;

17
test/compile_time.hpp Normal file
View File

@@ -0,0 +1,17 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/config.hpp>
#include <boost/mpl/assert.hpp>
template <class T>
struct compile_time_tests
{
BOOST_MPL_ASSERT((boost::is_base_and_derived<
std::unary_function<T, std::size_t>, boost::hash<T> >));
BOOST_STATIC_CONSTANT(bool, success = true);
};

59
test/hash_custom_test.cpp Normal file
View File

@@ -0,0 +1,59 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <vector>
#include <string>
#include <cctype>
namespace test
{
struct custom
{
int value_;
custom(int x) : value_(x) {}
std::size_t hash() const { return value_ * 10; }
};
}
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace test
#else
namespace boost
#endif
{
std::size_t hash_value(custom x)
{
return x.hash();
}
}
BOOST_AUTO_UNIT_TEST(custom_tests)
{
boost::hash<test::custom> custom_hasher;
BOOST_CHECK_EQUAL(custom_hasher(10), 100u);
test::custom x(55);
BOOST_CHECK_EQUAL(custom_hasher(x), 550u);
std::vector<test::custom> custom_vector;
custom_vector.push_back(5);
custom_vector.push_back(25);
custom_vector.push_back(35);
std::size_t seed = 0;
boost::hash_combine(seed, test::custom(5));
boost::hash_combine(seed, test::custom(25));
boost::hash_combine(seed, test::custom(35));
BOOST_CHECK_EQUAL(seed,
boost::hash_range(custom_vector.begin(), custom_vector.end()));
}

16
test/hash_deque_test.cpp Normal file
View File

@@ -0,0 +1,16 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/deque.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <deque>
using std::deque;
#define CONTAINER_TYPE deque
#include "./hash_sequence_test.hpp"

102
test/hash_float_test.cpp Normal file
View File

@@ -0,0 +1,102 @@
// Copyright Daniel James 2005. Use, modification, and distribution are
// subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <cmath>
#include <boost/limits.hpp>
template <class T>
void float_tests(T* = 0)
{
boost::hash<T> x1;
T zero = 0;
T minus_zero = (T) -1 * zero;
BOOST_CHECK_EQUAL(zero, minus_zero);
BOOST_CHECK_EQUAL(x1(zero), x1(minus_zero));
using namespace std;
if(std::numeric_limits<T>::has_infinity) {
T infinity = (T) 1. / zero;
T infinity2 = -log(zero);
T infinity3 = (T) -1. / minus_zero;
T infinity4 = std::numeric_limits<T>::infinity();
T minus_infinity = (T) -1. / zero;
T minus_infinity2 = log(zero);
T minus_infinity3 = (T) 1. / minus_zero;
BOOST_CHECK_EQUAL(infinity, infinity2);
BOOST_CHECK_EQUAL(infinity, infinity3);
BOOST_CHECK_EQUAL(infinity, infinity4);
BOOST_CHECK_EQUAL(x1(infinity), x1(infinity2));
BOOST_CHECK_EQUAL(x1(infinity), x1(infinity3));
BOOST_CHECK_EQUAL(x1(infinity), x1(infinity4));
BOOST_CHECK_EQUAL(minus_infinity, minus_infinity2);
BOOST_CHECK_EQUAL(x1(minus_infinity), x1(infinity2));
BOOST_CHECK_EQUAL(minus_infinity, minus_infinity3);
BOOST_CHECK_EQUAL(x1(minus_infinity), x1(minus_infinity3));
BOOST_CHECK(infinity != minus_infinity);
// My hash fails this one, I guess it's not that bad.
BOOST_WARN(x1(infinity) != x1(minus_infinity));
if(std::numeric_limits<T>::has_denorm == denorm_present) {
BOOST_CHECK(x1(std::numeric_limits<T>::denorm_min()) != x1(infinity));
BOOST_CHECK(x1(std::numeric_limits<T>::denorm_min()) != x1(minus_infinity));
}
if(std::numeric_limits<T>::has_quiet_NaN) {
// Another two failures, should I work around this?
BOOST_WARN(x1(std::numeric_limits<T>::quiet_NaN()) != x1(infinity));
BOOST_WARN(x1(std::numeric_limits<T>::quiet_NaN()) != x1(minus_infinity));
}
}
T max = (std::numeric_limits<T>::max)();
T half_max = max / 2;
T quater_max = max / 4;
T three_quater_max = max - quater_max;
BOOST_CHECK_EQUAL(x1(max), x1(max));
BOOST_CHECK(x1(max) != x1(quater_max));
BOOST_CHECK(x1(max) != x1(half_max));
BOOST_CHECK(x1(max) != x1(three_quater_max));
BOOST_CHECK_EQUAL(x1(quater_max), x1(quater_max));
BOOST_CHECK(x1(quater_max) != x1(half_max));
BOOST_CHECK(x1(quater_max) != x1(three_quater_max));
BOOST_CHECK_EQUAL(x1(half_max), x1(half_max));
BOOST_CHECK(x1(half_max) != x1(three_quater_max));
BOOST_CHECK(x1(three_quater_max) == x1(three_quater_max));
T v1 = asin((T) 1);
T v2 = acos((T) 0);
BOOST_CHECK_EQUAL(v1, v2);
BOOST_CHECK_EQUAL(x1(v1), x1(v2));
BOOST_CHECK(x1(std::numeric_limits<T>::epsilon()) != x1((T) 0));
if(std::numeric_limits<T>::has_denorm == denorm_present) {
BOOST_CHECK(x1(std::numeric_limits<T>::denorm_min()) != x1(zero));
}
if(std::numeric_limits<T>::has_quiet_NaN) {
BOOST_CHECK(x1(std::numeric_limits<T>::quiet_NaN()) != x1(zero));
}
}
BOOST_AUTO_UNIT_TEST(hash_float_tests)
{
float_tests((float*) 0);
float_tests((double*) 0);
float_tests((long double*) 0);
}

17
test/hash_list_test.cpp Normal file
View File

@@ -0,0 +1,17 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/list.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <list>
using std::list;
#define CONTAINER_TYPE list
#include "./hash_sequence_test.hpp"

21
test/hash_map_test.cpp Normal file
View File

@@ -0,0 +1,21 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/map.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <map>
using std::map;
#define CONTAINER_TYPE map
#include "./hash_map_test.hpp"
using std::multimap;
#define CONTAINER_TYPE multimap
#include "./hash_map_test.hpp"

56
test/hash_map_test.hpp Normal file
View File

@@ -0,0 +1,56 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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)
#if !defined(CONTAINER_TYPE)
#error "CONTAINER_TYPE not defined"
#else
#include <boost/preprocessor/cat.hpp>
#include <boost/assign/list_inserter.hpp>
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
{
template <class T>
void integer_tests(T* = 0)
{
const int number_of_containers = 10;
T containers[number_of_containers];
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < i; ++j)
boost::assign::insert(containers[i])(0,0);
}
boost::assign::insert(containers[6])(1,0);
boost::assign::insert(containers[7])(1,0)(1,0);
boost::assign::insert(containers[8])(-1,1);
boost::assign::insert(containers[9])(-1,3)(-1,3);
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(
(containers[i2] == containers[j2]) ==
(hasher(containers[i2]) == hasher(containers[j2]))
);
}
}
}
BOOST_AUTO_UNIT_TEST(BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests))
{
integer_tests((CONTAINER_TYPE<char, unsigned char>*) 0);
integer_tests((CONTAINER_TYPE<int, float>*) 0);
integer_tests((CONTAINER_TYPE<unsigned long, unsigned long>*) 0);
integer_tests((CONTAINER_TYPE<double, short>*) 0);
}
}
#undef CONTAINER_TYPE
#endif

69
test/hash_number_test.cpp Normal file
View File

@@ -0,0 +1,69 @@
// Copyright Daniel James 2005. Use, modification, and distribution are
// subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/limits.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include "./compile_time.hpp"
template <class T>
void numeric_test()
{
BOOST_CHECK(compile_time_tests<T>::success);
boost::hash<T> x1;
boost::hash<T> x2;
BOOST_CHECK_EQUAL(x1(T(0)), x2(T(0)));
BOOST_CHECK_EQUAL(x1(T(10)), x2(T(10)));
BOOST_CHECK_EQUAL(x1(T(25)), x2(T(25)));
BOOST_CHECK_EQUAL(x1(T(5) - T(5)), x2(T(0)));
BOOST_CHECK_EQUAL(x1(T(6) + T(4)), x2(T(10)));
typedef std::numeric_limits<T> limits;
BOOST_CHECK(limits::is_specialized);
BOOST_CHECK_EQUAL(x1((limits::min)()), x2((limits::min)()));
BOOST_CHECK_EQUAL(x1((limits::max)()), x2((limits::max)()));
// A hash function can legally fail these tests, but it'll not be a good
// sign.
BOOST_CHECK_EQUAL((T(1) != T(-1)), (x1(T(1)) != x2(T(-1))));
BOOST_CHECK_EQUAL((T(1) != T(2)), (x1(T(1)) != x2(T(2))));
BOOST_CHECK_EQUAL(
((limits::max)() != (limits::max)() - 1),
(x1((limits::max)()) != x2((limits::max)() - 1)));
}
#define NUMERIC_TEST(type, name) \
BOOST_AUTO_UNIT_TEST(BOOST_PP_CAT(test_, name)) { \
numeric_test<type>(); \
}
NUMERIC_TEST(bool, bool)
NUMERIC_TEST(char, char)
NUMERIC_TEST(signed char, schar)
NUMERIC_TEST(unsigned char, uchar)
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
NUMERIC_TEST(wchar_t, wchar)
#endif
NUMERIC_TEST(short, short)
NUMERIC_TEST(unsigned short, ushort)
NUMERIC_TEST(int, int)
NUMERIC_TEST(unsigned int, uint)
NUMERIC_TEST(long, hash_long)
NUMERIC_TEST(unsigned long, ulong)
NUMERIC_TEST(float, float)
NUMERIC_TEST(double, double)
NUMERIC_TEST(long double, ldouble)

View File

@@ -0,0 +1,31 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/limits.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include "./compile_time.hpp"
BOOST_AUTO_UNIT_TEST(pointer_tests)
{
BOOST_CHECK(compile_time_tests<int*>::success);
BOOST_CHECK(compile_time_tests<void*>::success);
boost::hash<int*> x1;
boost::hash<int*> x2;
int int1;
int int2;
BOOST_CHECK_EQUAL(x1(0), x2(0));
BOOST_CHECK_EQUAL(x1(&int1), x2(&int1));
BOOST_CHECK_EQUAL(x1(&int2), x2(&int2));
}

46
test/hash_range_test.cpp Normal file
View File

@@ -0,0 +1,46 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/limits.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/assign/list_inserter.hpp>
BOOST_AUTO_UNIT_TEST(hash_range_tests)
{
using namespace boost::assign;
std::vector<int> empty, values1, values2, values3, values4, values5;
push_back(values1)(0);
push_back(values2)(10);
push_back(values3)(10)(20);
push_back(values4)(15)(75);
push_back(values5)(10)(20)(15)(75)(10)(20);
std::vector<int> x;
BOOST_CHECK_EQUAL(boost::hash_range(empty), boost::hash_range(x));
BOOST_CHECK_EQUAL(boost::hash_range(empty), boost::hash_range(x.begin(), x.end()));
BOOST_CHECK(boost::hash_range(empty) != boost::hash_range(values1));
x.push_back(10);
BOOST_CHECK(boost::hash_range(empty) != boost::hash_range(x));
BOOST_CHECK_EQUAL(boost::hash_range(values2), boost::hash_range(x));
BOOST_CHECK_EQUAL(boost::hash_range(values2), boost::hash_range(x.begin(), x.end()));
x.push_back(20);
BOOST_CHECK(boost::hash_range(empty) != boost::hash_range(x));
BOOST_CHECK(boost::hash_range(values2) != boost::hash_range(x));
BOOST_CHECK_EQUAL(boost::hash_range(values3), boost::hash_range(x));
std::size_t seed = boost::hash_range(values3);
boost::hash_range(seed, boost::const_begin(values4), boost::const_end(values4));
boost::hash_range(seed, x);
BOOST_CHECK_EQUAL(seed, boost::hash_range(values5));
}

View File

@@ -0,0 +1,60 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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)
#if !defined(CONTAINER_TYPE)
#error "CONTAINER_TYPE not defined"
#else
#include <boost/preprocessor/cat.hpp>
#include <boost/assign/list_inserter.hpp>
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
{
template <class T>
void integer_tests(T* = 0)
{
using namespace boost::assign;
const int number_of_containers = 11;
T containers[number_of_containers];
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < i; ++j)
boost::assign::push_back(containers[i])(0);
}
boost::assign::push_back(containers[5])(1);
boost::assign::push_back(containers[6])(1)(1);
boost::assign::push_back(containers[7])(-1);
boost::assign::push_back(containers[8])(-1)(-1);
boost::assign::push_back(containers[9])(1)(-1);
boost::assign::push_back(containers[10])(-1)(1);
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(
(containers[i2] == containers[j2]) ==
(hasher(containers[i2]) == hasher(containers[j2]))
);
}
}
}
BOOST_AUTO_UNIT_TEST(BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests))
{
integer_tests((CONTAINER_TYPE<char>*) 0);
integer_tests((CONTAINER_TYPE<int>*) 0);
integer_tests((CONTAINER_TYPE<unsigned long>*) 0);
integer_tests((CONTAINER_TYPE<double>*) 0);
}
}
#undef CONTAINER_TYPE
#endif

20
test/hash_set_test.cpp Normal file
View File

@@ -0,0 +1,20 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/set.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <set>
using std::set;
#define CONTAINER_TYPE set
#include "./hash_set_test.hpp"
using std::multiset;
#define CONTAINER_TYPE multiset
#include "./hash_set_test.hpp"

59
test/hash_set_test.hpp Normal file
View File

@@ -0,0 +1,59 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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)
#if !defined(CONTAINER_TYPE)
#error "CONTAINER_TYPE not defined"
#else
#include <boost/preprocessor/cat.hpp>
#include <boost/assign/list_inserter.hpp>
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
{
template <class T>
void integer_tests(T* = 0)
{
using namespace boost::assign;
const int number_of_containers = 11;
T containers[number_of_containers];
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < i; ++j)
boost::assign::insert(containers[i])(0);
}
boost::assign::insert(containers[6])(1);
boost::assign::insert(containers[7])(1)(1);
boost::assign::insert(containers[8])(-1);
boost::assign::insert(containers[9])(-1)(-1);
boost::assign::insert(containers[10])(-1)(1);
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(
(containers[i2] == containers[j2]) ==
(hasher(containers[i2]) == hasher(containers[j2]))
);
}
}
}
BOOST_AUTO_UNIT_TEST(BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests))
{
integer_tests((CONTAINER_TYPE<char>*) 0);
integer_tests((CONTAINER_TYPE<int>*) 0);
integer_tests((CONTAINER_TYPE<unsigned long>*) 0);
integer_tests((CONTAINER_TYPE<double>*) 0);
}
}
#undef CONTAINER_TYPE
#endif

39
test/hash_string_test.cpp Normal file
View File

@@ -0,0 +1,39 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/hash.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/limits.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include "./compile_time.hpp"
BOOST_AUTO_UNIT_TEST(string_tests)
{
BOOST_CHECK(compile_time_tests<std::string>::success);
boost::hash<std::string> x1;
boost::hash<std::string> x2;
BOOST_CHECK_EQUAL(x1("Hello"), x2(std::string("Hel") + "lo"));
BOOST_CHECK_EQUAL(x1(""), x2(std::string()));
}
#if !defined(BOOST_NO_STD_WSTRING)
BOOST_AUTO_UNIT_TEST(wstring_tests)
{
BOOST_CHECK(compile_time_tests<std::wstring>::success);
boost::hash<std::wstring> x1;
boost::hash<std::wstring> x2;
BOOST_CHECK_EQUAL(x1(L"Hello"), x2(std::wstring(L"Hel") + L"lo"));
BOOST_CHECK_EQUAL(x1(L""), x2(std::wstring()));
}
#endif

16
test/hash_vector_test.cpp Normal file
View File

@@ -0,0 +1,16 @@
// (C) Copyright Daniel James 2005.
// Use, modification and distribution are subject to 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 <boost/functional/hash/vector.hpp>
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <vector>
using std::vector;
#define CONTAINER_TYPE vector
#include "./hash_sequence_test.hpp"