More tests for unordered associative containers.

[SVN r2959]
This commit is contained in:
Daniel James
2006-05-21 17:14:11 +00:00
parent 822b0c7ffd
commit fbd37a946b
28 changed files with 1975 additions and 86 deletions
+8 -5
View File
@@ -17,6 +17,7 @@ void copy_construct_tests1(T* = 0)
{
typename T::hasher hf;
typename T::key_equal eq;
typename T::allocator_type al;
{
T x;
@@ -24,6 +25,7 @@ void copy_construct_tests1(T* = 0)
BOOST_TEST(y.empty());
BOOST_TEST(test::equivalent(y.hash_function(), hf));
BOOST_TEST(test::equivalent(y.key_eq(), eq));
BOOST_TEST(test::equivalent(y.get_allocator(), al));
BOOST_TEST(x.max_load_factor() == y.max_load_factor());
test::check_equivalent_keys(y);
}
@@ -42,15 +44,14 @@ void copy_construct_tests1(T* = 0)
// In this test I drop the original containers max load factor, so it
// is much lower than the load factor. The hash table is not allowed
// to rehash, but the destination container should probably allocate
// enough buckets to decrease the load factor appropriately. Although,
// I don't think it has to.
// enough buckets to decrease the load factor appropriately.
test::random_values<T> v(1000);
T x(v.begin(), v.end());
x.max_load_factor(x.load_factor() / 4);
T y(x);
test::unordered_equivalence_tester<T> equivalent(x);
equivalent(y);
// I don't think this is guaranteed:
// This isn't guaranteed:
BOOST_TEST(y.load_factor() < y.max_load_factor());
test::check_equivalent_keys(y);
}
@@ -63,14 +64,16 @@ void copy_construct_tests2(T* ptr = 0)
typename T::hasher hf(1);
typename T::key_equal eq(1);
typename T::allocator_type al(1);
{
// TODO: I could check how many buckets y has, it should be lower (QOI issue).
T x(10000, hf, eq);
T x(10000, hf, eq, al);
T y(x);
BOOST_TEST(y.empty());
BOOST_TEST(test::equivalent(y.hash_function(), hf));
BOOST_TEST(test::equivalent(y.key_eq(), eq));
BOOST_TEST(test::equivalent(y.get_allocator(), al));
BOOST_TEST(x.max_load_factor() == y.max_load_factor());
test::check_equivalent_keys(y);
}
@@ -79,7 +82,7 @@ void copy_construct_tests2(T* ptr = 0)
// TODO: Invariant checks are especially important here.
test::random_values<T> v(1000);
T x(v.begin(), v.end(), 0, hf, eq);
T x(v.begin(), v.end(), 0, hf, eq, al);
T y(x);
test::unordered_equivalence_tester<T> equivalent(x);
equivalent(y);