In hash_fwd_test avoid a Borland bug by putting the test classes in a namespace.

Seems to break on gcc 2.95 though...

Also use HASH_NAMESPACE instead of boost to allow tests to be run in 'std'.


[SVN r32686]
This commit is contained in:
Daniel James
2006-02-07 00:48:58 +00:00
parent 3cb7963112
commit bb702b827e
3 changed files with 45 additions and 40 deletions
+23 -23
View File
@@ -12,40 +12,40 @@
#if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES)
#include <boost/functional/hash.hpp>
#include <boost/functional/hash/hash.hpp>
#include <string>
BOOST_AUTO_TEST_CASE(fwd_test1)
{
test_type1<int> x(5);
test_type1<std::string> y("Test");
test::test_type1<int> x(5);
test::test_type1<std::string> y("Test");
BOOST_CHECK_EQUAL(
boost::hash<int>()(5),
boost::hash<test_type1<int> >()(x));
HASH_NAMESPACE::hash<int>()(5),
HASH_NAMESPACE::hash<test::test_type1<int> >()(x));
BOOST_CHECK_EQUAL(
boost::hash<std::string>()("Test"),
boost::hash<test_type1<std::string> >()(y));
HASH_NAMESPACE::hash<std::string>()("Test"),
HASH_NAMESPACE::hash<test::test_type1<std::string> >()(y));
}
BOOST_AUTO_TEST_CASE(fwd_test2)
{
test_type2<int> x(5, 10);
test_type2<std::string> y("Test1", "Test2");
test::test_type2<int> x(5, 10);
test::test_type2<std::string> y("Test1", "Test2");
std::size_t seed1 = 0;
boost::hash_combine(seed1, 5);
boost::hash_combine(seed1, 10);
HASH_NAMESPACE::hash_combine(seed1, 5);
HASH_NAMESPACE::hash_combine(seed1, 10);
std::size_t seed2 = 0;
boost::hash_combine(seed2, std::string("Test1"));
boost::hash_combine(seed2, std::string("Test2"));
HASH_NAMESPACE::hash_combine(seed2, std::string("Test1"));
HASH_NAMESPACE::hash_combine(seed2, std::string("Test2"));
BOOST_CHECK_EQUAL(seed1,
boost::hash<test_type2<int> >()(x));
HASH_NAMESPACE::hash<test::test_type2<int> >()(x));
BOOST_CHECK_EQUAL(seed2,
boost::hash<test_type2<std::string> >()(y));
HASH_NAMESPACE::hash<test::test_type2<std::string> >()(y));
}
BOOST_AUTO_TEST_CASE(fwd_test3)
@@ -63,19 +63,19 @@ BOOST_AUTO_TEST_CASE(fwd_test3)
values2.push_back("Gummo");
values2.push_back("Zeppo");
test_type3<int> x(values1.begin(), values1.end());
test_type3<std::string> y(values2.begin(), values2.end());
test::test_type3<int> x(values1.begin(), values1.end());
test::test_type3<std::string> y(values2.begin(), values2.end());
std::size_t seed1 = boost::hash_range(values1.begin(), values1.end());
boost::hash_range(seed1, values1.begin(), values1.end());
std::size_t seed1 = HASH_NAMESPACE::hash_range(values1.begin(), values1.end());
HASH_NAMESPACE::hash_range(seed1, values1.begin(), values1.end());
std::size_t seed2 = boost::hash_range(values2.begin(), values2.end());
boost::hash_range(seed2, values2.begin(), values2.end());
std::size_t seed2 = HASH_NAMESPACE::hash_range(values2.begin(), values2.end());
HASH_NAMESPACE::hash_range(seed2, values2.begin(), values2.end());
BOOST_CHECK_EQUAL(seed1,
boost::hash<test_type3<int> >()(x));
HASH_NAMESPACE::hash<test::test_type3<int> >()(x));
BOOST_CHECK_EQUAL(seed2,
boost::hash<test_type3<std::string> >()(y));
HASH_NAMESPACE::hash<test::test_type3<std::string> >()(y));
}
#endif