Removes uses of BOOST_CHECK_EQUAL from the hash tests as they don't work on Borland.

Also force a failure on the float tests on borland as they are crashing horribly. Hopefully I should be able to fix this and remove this.

Also use pair's constructor in hash_map_test.hpp instead of make_pair so that the correct type is created.


[SVN r28049]
This commit is contained in:
Daniel James
2005-04-07 20:53:20 +00:00
parent a65dc47fcb
commit 2d91127422
9 changed files with 56 additions and 50 deletions

View File

@@ -39,9 +39,9 @@ namespace boost
BOOST_AUTO_UNIT_TEST(custom_tests)
{
boost::hash<test::custom> custom_hasher;
BOOST_CHECK_EQUAL(custom_hasher(10), 100u);
BOOST_CHECK(custom_hasher(10) == 100u);
test::custom x(55);
BOOST_CHECK_EQUAL(custom_hasher(x), 550u);
BOOST_CHECK(custom_hasher(x) == 550u);
std::vector<test::custom> custom_vector;
custom_vector.push_back(5);
@@ -53,7 +53,7 @@ BOOST_AUTO_UNIT_TEST(custom_tests)
boost::hash_combine(seed, test::custom(25));
boost::hash_combine(seed, test::custom(35));
BOOST_CHECK_EQUAL(seed,
BOOST_CHECK(seed ==
boost::hash_range(custom_vector.begin(), custom_vector.end()));
}

View File

@@ -19,11 +19,16 @@ void float_tests(T* = 0)
T zero = 0;
T minus_zero = (T) -1 * zero;
BOOST_CHECK_EQUAL(zero, minus_zero);
BOOST_CHECK_EQUAL(x1(zero), x1(minus_zero));
BOOST_CHECK(zero == minus_zero);
BOOST_CHECK(x1(zero) == x1(minus_zero));
using namespace std;
// The tests cause Borland to crash horribly.
#if defined(__BORLANDC__)
BOOST_REQUIRE(false);
#endif
if(std::numeric_limits<T>::has_infinity) {
T infinity = (T) 1. / zero;
T infinity2 = -log(zero);
@@ -34,17 +39,17 @@ void float_tests(T* = 0)
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(infinity == infinity2);
BOOST_CHECK(infinity == infinity3);
BOOST_CHECK(infinity == infinity4);
BOOST_CHECK(x1(infinity) == x1(infinity2));
BOOST_CHECK(x1(infinity) == x1(infinity3));
BOOST_CHECK(x1(infinity) == x1(infinity4));
BOOST_CHECK_EQUAL(minus_infinity, minus_infinity2);
BOOST_CHECK_EQUAL(x1(minus_infinity), x1(minus_infinity2));
BOOST_CHECK_EQUAL(minus_infinity, minus_infinity3);
BOOST_CHECK_EQUAL(x1(minus_infinity), x1(minus_infinity3));
BOOST_CHECK(minus_infinity == minus_infinity2);
BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity2));
BOOST_CHECK(minus_infinity == minus_infinity3);
BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity3));
BOOST_CHECK(infinity != minus_infinity);
@@ -69,21 +74,21 @@ void float_tests(T* = 0)
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(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(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(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(v1 == v2);
BOOST_CHECK(x1(v1) == x1(v2));
BOOST_CHECK(x1(std::numeric_limits<T>::epsilon()) != x1((T) 0));

View File

@@ -17,23 +17,24 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
{
const int number_of_containers = 10;
T containers[number_of_containers];
typedef typename T::value_type pair;
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < i; ++j)
containers[i].insert(std::make_pair(0, 0));
containers[i].insert(pair(0, 0));
}
containers[6].insert(std::make_pair(1,0));
containers[7].insert(std::make_pair(1,0));
containers[7].insert(std::make_pair(1,0));
containers[8].insert(std::make_pair(-1,1));
containers[9].insert(std::make_pair(-1,3));
containers[9].insert(std::make_pair(-1,3));
containers[6].insert(pair(1,0));
containers[7].insert(pair(1,0));
containers[7].insert(pair(1,0));
containers[8].insert(pair(-1,1));
containers[9].insert(pair(-1,3));
containers[9].insert(pair(-1,3));
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(

View File

@@ -23,19 +23,19 @@ void numeric_test()
boost::hash<T> x1;
boost::hash<T> x2;
BOOST_CHECK_EQUAL(x1(T(0)), x2(T(0)));
BOOST_CHECK(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(x1(T(10)) == x2(T(10)));
BOOST_CHECK(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)));
BOOST_CHECK(x1(T(5) - T(5)) == x2(T(0)));
BOOST_CHECK(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)()));
BOOST_CHECK(x1((limits::min)()) == x2((limits::min)()));
BOOST_CHECK(x1((limits::max)()) == x2((limits::max)()));
// A hash function can legally fail these tests, but it'll not be a good
// sign.

View File

@@ -25,7 +25,7 @@ BOOST_AUTO_UNIT_TEST(pointer_tests)
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));
BOOST_CHECK(x1(0) == x2(0));
BOOST_CHECK(x1(&int1) == x2(&int1));
BOOST_CHECK(x1(&int2) == x2(&int2));
}

View File

@@ -25,22 +25,22 @@ BOOST_AUTO_UNIT_TEST(hash_range_tests)
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(x));
BOOST_CHECK(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()));
BOOST_CHECK(boost::hash_range(values2) == boost::hash_range(x));
BOOST_CHECk(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));
BOOST_CHECK(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));
BOOST_CHECK(seed == boost::hash_range(values5));
}

View File

@@ -37,7 +37,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(

View File

@@ -35,7 +35,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
boost::hash<T> hasher;
for(int i2 = 0; i2 < number_of_containers; ++i2) {
BOOST_CHECK_EQUAL(hasher(containers[i2]), hasher(containers[i2]));
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
BOOST_CHECK(

View File

@@ -21,8 +21,8 @@ BOOST_AUTO_UNIT_TEST(string_tests)
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()));
BOOST_CHECK(x1("Hello") == x2(std::string("Hel") + "lo"));
BOOST_CHECK(x1("") == x2(std::string()));
}
#if !defined(BOOST_NO_STD_WSTRING)
@@ -33,7 +33,7 @@ BOOST_AUTO_UNIT_TEST(wstring_tests)
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()));
BOOST_CHECK(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo"));
BOOST_CHECK(x1(L"") == x2(std::wstring()));
}
#endif