diff --git a/hash/test/Jamfile b/hash/test/Jamfile new file mode 100644 index 0000000..d77ae3f --- /dev/null +++ b/hash/test/Jamfile @@ -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 + ../../../test/build/boost_unit_test_framework + : : : $(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 ] + ; +} diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 new file mode 100644 index 0000000..4daa642 --- /dev/null +++ b/hash/test/Jamfile.v2 @@ -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 ] + ; diff --git a/hash/test/compile_time.hpp b/hash/test/compile_time.hpp new file mode 100644 index 0000000..c4b1720 --- /dev/null +++ b/hash/test/compile_time.hpp @@ -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 +#include + +template +struct compile_time_tests +{ + BOOST_MPL_ASSERT((boost::is_base_and_derived< + std::unary_function, boost::hash >)); + BOOST_STATIC_CONSTANT(bool, success = true); +}; + diff --git a/hash/test/hash_custom_test.cpp b/hash/test/hash_custom_test.cpp new file mode 100644 index 0000000..b4bc5e7 --- /dev/null +++ b/hash/test/hash_custom_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include +#include + +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 custom_hasher; + BOOST_CHECK_EQUAL(custom_hasher(10), 100u); + test::custom x(55); + BOOST_CHECK_EQUAL(custom_hasher(x), 550u); + + std::vector 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())); +} + diff --git a/hash/test/hash_deque_test.cpp b/hash/test/hash_deque_test.cpp new file mode 100644 index 0000000..ac8e0bd --- /dev/null +++ b/hash/test/hash_deque_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include + +using std::deque; +#define CONTAINER_TYPE deque +#include "./hash_sequence_test.hpp" diff --git a/hash/test/hash_float_test.cpp b/hash/test/hash_float_test.cpp new file mode 100644 index 0000000..09839a5 --- /dev/null +++ b/hash/test/hash_float_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include + +template +void float_tests(T* = 0) +{ + boost::hash 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::has_infinity) { + T infinity = (T) 1. / zero; + T infinity2 = -log(zero); + T infinity3 = (T) -1. / minus_zero; + T infinity4 = std::numeric_limits::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::has_denorm == denorm_present) { + BOOST_CHECK(x1(std::numeric_limits::denorm_min()) != x1(infinity)); + BOOST_CHECK(x1(std::numeric_limits::denorm_min()) != x1(minus_infinity)); + } + + if(std::numeric_limits::has_quiet_NaN) { + // Another two failures, should I work around this? + BOOST_WARN(x1(std::numeric_limits::quiet_NaN()) != x1(infinity)); + BOOST_WARN(x1(std::numeric_limits::quiet_NaN()) != x1(minus_infinity)); + } + } + + T max = (std::numeric_limits::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::epsilon()) != x1((T) 0)); + + if(std::numeric_limits::has_denorm == denorm_present) { + BOOST_CHECK(x1(std::numeric_limits::denorm_min()) != x1(zero)); + } + + if(std::numeric_limits::has_quiet_NaN) { + BOOST_CHECK(x1(std::numeric_limits::quiet_NaN()) != x1(zero)); + } +} + +BOOST_AUTO_UNIT_TEST(hash_float_tests) +{ + float_tests((float*) 0); + float_tests((double*) 0); + float_tests((long double*) 0); +} diff --git a/hash/test/hash_list_test.cpp b/hash/test/hash_list_test.cpp new file mode 100644 index 0000000..ecba931 --- /dev/null +++ b/hash/test/hash_list_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include + +using std::list; +#define CONTAINER_TYPE list +#include "./hash_sequence_test.hpp" + diff --git a/hash/test/hash_map_test.cpp b/hash/test/hash_map_test.cpp new file mode 100644 index 0000000..fb8add3 --- /dev/null +++ b/hash/test/hash_map_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include + +using std::map; +#define CONTAINER_TYPE map +#include "./hash_map_test.hpp" + +using std::multimap; +#define CONTAINER_TYPE multimap +#include "./hash_map_test.hpp" + diff --git a/hash/test/hash_map_test.hpp b/hash/test/hash_map_test.hpp new file mode 100644 index 0000000..a37f6f8 --- /dev/null +++ b/hash/test/hash_map_test.hpp @@ -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 +#include + +namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +{ + template + 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 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*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + } +} + +#undef CONTAINER_TYPE +#endif diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp new file mode 100644 index 0000000..66e5b46 --- /dev/null +++ b/hash/test/hash_number_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include +#include +#include + +#include "./compile_time.hpp" + +template +void numeric_test() +{ + BOOST_CHECK(compile_time_tests::success); + + boost::hash x1; + boost::hash 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 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(); \ + } + +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) diff --git a/hash/test/hash_pointer_test.cpp b/hash/test/hash_pointer_test.cpp new file mode 100644 index 0000000..5fb1db8 --- /dev/null +++ b/hash/test/hash_pointer_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include +#include + +#include "./compile_time.hpp" + +BOOST_AUTO_UNIT_TEST(pointer_tests) +{ + BOOST_CHECK(compile_time_tests::success); + BOOST_CHECK(compile_time_tests::success); + + boost::hash x1; + boost::hash 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)); +} diff --git a/hash/test/hash_range_test.cpp b/hash/test/hash_range_test.cpp new file mode 100644 index 0000000..246f411 --- /dev/null +++ b/hash/test/hash_range_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include +#include +#include + +BOOST_AUTO_UNIT_TEST(hash_range_tests) +{ + using namespace boost::assign; + + std::vector 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 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)); +} diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp new file mode 100644 index 0000000..a9f3f11 --- /dev/null +++ b/hash/test/hash_sequence_test.hpp @@ -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 +#include + +namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +{ + template + 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 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*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + } +} + +#undef CONTAINER_TYPE +#endif diff --git a/hash/test/hash_set_test.cpp b/hash/test/hash_set_test.cpp new file mode 100644 index 0000000..3b12f54 --- /dev/null +++ b/hash/test/hash_set_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include + +using std::set; +#define CONTAINER_TYPE set +#include "./hash_set_test.hpp" + +using std::multiset; +#define CONTAINER_TYPE multiset +#include "./hash_set_test.hpp" diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp new file mode 100644 index 0000000..d83ae2a --- /dev/null +++ b/hash/test/hash_set_test.hpp @@ -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 +#include + +namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +{ + template + 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 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*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + integer_tests((CONTAINER_TYPE*) 0); + } +} + +#undef CONTAINER_TYPE +#endif diff --git a/hash/test/hash_string_test.cpp b/hash/test/hash_string_test.cpp new file mode 100644 index 0000000..f381ebc --- /dev/null +++ b/hash/test/hash_string_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include +#include +#include + +#include "./compile_time.hpp" + +BOOST_AUTO_UNIT_TEST(string_tests) +{ + BOOST_CHECK(compile_time_tests::success); + + boost::hash x1; + boost::hash 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::success); + + boost::hash x1; + boost::hash x2; + + BOOST_CHECK_EQUAL(x1(L"Hello"), x2(std::wstring(L"Hel") + L"lo")); + BOOST_CHECK_EQUAL(x1(L""), x2(std::wstring())); +} +#endif diff --git a/hash/test/hash_vector_test.cpp b/hash/test/hash_vector_test.cpp new file mode 100644 index 0000000..6337439 --- /dev/null +++ b/hash/test/hash_vector_test.cpp @@ -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 + +#define BOOST_AUTO_TEST_MAIN +#include + +#include + +using std::vector; +#define CONTAINER_TYPE vector +#include "./hash_sequence_test.hpp"