|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73754 - in trunk/libs/unordered/test: helpers unordered
From: dnljms_at_[hidden]
Date: 2011-08-14 14:52:45
Author: danieljames
Date: 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
New Revision: 73754
URL: http://svn.boost.org/trac/boost/changeset/73754
Log:
Unordered: Count instances in some tests.
Text files modified:
trunk/libs/unordered/test/helpers/count.hpp | 7 ++++++
trunk/libs/unordered/test/unordered/assign_tests.cpp | 8 +++++++
trunk/libs/unordered/test/unordered/bucket_tests.cpp | 2 +
trunk/libs/unordered/test/unordered/constructor_tests.cpp | 43 ++++++++++++++++++++++++++++++++++++++++
trunk/libs/unordered/test/unordered/copy_tests.cpp | 14 +++++++++++++
trunk/libs/unordered/test/unordered/erase_tests.cpp | 14 +++++++++++++
trunk/libs/unordered/test/unordered/find_tests.cpp | 4 +++
trunk/libs/unordered/test/unordered/insert_tests.cpp | 23 +++++++++++++++++++++
trunk/libs/unordered/test/unordered/move_tests.cpp | 12 +++++++++++
trunk/libs/unordered/test/unordered/swap_tests.cpp | 18 ++++++++++++++++
10 files changed, 145 insertions(+), 0 deletions(-)
Modified: trunk/libs/unordered/test/helpers/count.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/count.hpp (original)
+++ trunk/libs/unordered/test/helpers/count.hpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -75,6 +75,13 @@
namespace {
object_count& global_object_count = globally_counted_object::count_;
}
+
+ struct check_instances {
+ int instances;
+
+ check_instances() : instances(global_object_count.instances) {}
+ ~check_instances() { BOOST_TEST(global_object_count.instances == instances); }
+ };
}
#endif
Modified: trunk/libs/unordered/test/unordered/assign_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/assign_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/assign_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -28,6 +28,8 @@
std::cerr<<"assign_tests1.1\n";
{
+ test::check_instances check_;
+
T x;
x = x;
BOOST_TEST(x.empty());
@@ -37,6 +39,8 @@
std::cerr<<"assign_tests1.2\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
@@ -67,6 +71,8 @@
std::cerr<<"assign_tests2.1\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x1(v.begin(), v.end(), 0, hf1, eq1);
T x2(0, hf2, eq2);
@@ -78,6 +84,8 @@
std::cerr<<"assign_tests2.2\n";
{
+ test::check_instances check_;
+
test::random_values<T> v1(100, generator), v2(100, generator);
T x1(v1.begin(), v1.end(), 0, hf1, eq1, al1);
T x2(v2.begin(), v2.end(), 0, hf2, eq2, al2);
Modified: trunk/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/bucket_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -25,6 +25,8 @@
template <class X>
void tests(X* = 0, test::random_generator generator = test::default_generator)
{
+ test::check_instances check_;
+
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
test::random_values<X> v(1000, generator);
Modified: trunk/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/constructor_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -31,6 +31,8 @@
std::cerr<<"Construct 1\n";
{
+ test::check_instances check_;
+
T x(0, hf, eq);
BOOST_TEST(x.empty());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -41,6 +43,8 @@
std::cerr<<"Construct 2\n";
{
+ test::check_instances check_;
+
T x(100, hf);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 100);
@@ -52,6 +56,8 @@
std::cerr<<"Construct 3\n";
{
+ test::check_instances check_;
+
T x(2000);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 2000);
@@ -63,6 +69,8 @@
std::cerr<<"Construct 4\n";
{
+ test::check_instances check_;
+
T x;
BOOST_TEST(x.empty());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -73,6 +81,8 @@
std::cerr<<"Construct 5\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 10000, hf, eq);
BOOST_TEST(x.bucket_count() >= 10000);
@@ -85,6 +95,8 @@
std::cerr<<"Construct 6\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(10, generator);
T x(v.begin(), v.end(), 10000, hf);
BOOST_TEST(x.bucket_count() >= 10000);
@@ -97,6 +109,8 @@
std::cerr<<"Construct 7\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 100);
BOOST_TEST(x.bucket_count() >= 100);
@@ -109,6 +123,8 @@
std::cerr<<"Construct 8\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(1, generator);
T x(v.begin(), v.end());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -120,6 +136,8 @@
std::cerr<<"Construct 9\n";
{
+ test::check_instances check_;
+
T x(0, hf, eq, al);
BOOST_TEST(x.empty());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -130,6 +148,8 @@
std::cerr<<"Construct 10\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 10000, hf, eq, al);
BOOST_TEST(x.bucket_count() >= 10000);
@@ -142,6 +162,8 @@
std::cerr<<"Construct 11\n";
{
+ test::check_instances check_;
+
T x(al);
BOOST_TEST(x.empty());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -167,6 +189,7 @@
std::cerr<<"Construct 1\n";
{
+ test::check_instances check_;
T x(10000, hf1, eq1);
BOOST_TEST(x.bucket_count() >= 10000);
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
@@ -177,6 +200,7 @@
std::cerr<<"Construct 2\n";
{
+ test::check_instances check_;
T x(100, hf1);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 100);
@@ -188,6 +212,7 @@
std::cerr<<"Construct 3\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
@@ -199,6 +224,7 @@
std::cerr<<"Construct 4\n";
{
+ test::check_instances check_;
test::random_values<T> v(5, generator);
T x(v.begin(), v.end(), 1000, hf1);
BOOST_TEST(x.bucket_count() >= 1000);
@@ -212,6 +238,7 @@
std::cerr<<"Construct 5\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf, eq, al1);
T y(x.begin(), x.end(), 0, hf1, eq1, al2);
@@ -223,6 +250,7 @@
std::cerr<<"Construct 6\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
T y(x.begin(), x.end(), 0, hf, eq);
@@ -234,6 +262,7 @@
std::cerr<<"Construct 7\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
T x(v.begin(), v.end(), 0, hf1, eq1);
T y(x.begin(), x.end(), 0, hf2, eq2);
@@ -245,6 +274,7 @@
std::cerr<<"Construct 8 - from input iterator\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
v_begin = v.begin(), v_end = v.end();
@@ -262,6 +292,7 @@
std::cerr<<"Construct 8.5 - from copy iterator\n";
{
+ test::check_instances check_;
test::random_values<T> v(100, generator);
T x(test::copy_iterator(v.begin()),
test::copy_iterator(v.end()), 0, hf1, eq1);
@@ -275,6 +306,8 @@
std::cerr<<"Construct 9\n";
{
+ test::check_instances check_;
+
test::random_values<T> v(100, generator);
T x(50);
BOOST_TEST(x.bucket_count() >= 50);
@@ -291,6 +324,8 @@
std::cerr<<"Initializer list construct 1\n";
{
+ test::check_instances check_;
+
T x(list);
BOOST_TEST(x.empty());
BOOST_TEST(test::equivalent(x.hash_function(), hf));
@@ -300,6 +335,8 @@
std::cerr<<"Initializer list construct 2\n";
{
+ test::check_instances check_;
+
T x(list, 1000);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 1000);
@@ -310,6 +347,8 @@
std::cerr<<"Initializer list construct 3\n";
{
+ test::check_instances check_;
+
T x(list, 10, hf1);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 10);
@@ -320,6 +359,8 @@
std::cerr<<"Initializer list construct 4\n";
{
+ test::check_instances check_;
+
T x(list, 10, hf1, eq1);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 10);
@@ -330,6 +371,8 @@
std::cerr<<"Initializer list construct 5\n";
{
+ test::check_instances check_;
+
T x(list, 10, hf1, eq1, al1);
BOOST_TEST(x.empty());
BOOST_TEST(x.bucket_count() >= 10);
Modified: trunk/libs/unordered/test/unordered/copy_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/copy_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/copy_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -28,6 +28,8 @@
BOOST_DEDUCED_TYPENAME T::allocator_type al;
{
+ test::check_instances check_;
+
T x;
T y(x);
BOOST_TEST(y.empty());
@@ -39,6 +41,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
@@ -49,6 +53,8 @@
}
{
+ test::check_instances check_;
+
// 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
@@ -77,6 +83,8 @@
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
{
+ test::check_instances check_;
+
T x(10000, hf, eq, al);
T y(x);
BOOST_TEST(y.empty());
@@ -88,6 +96,8 @@
}
{
+ test::check_instances check_;
+
T x(1000, hf, eq, al);
T y(x, al2);
BOOST_TEST(y.empty());
@@ -99,6 +109,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
@@ -110,6 +122,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<T> v(500, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
Modified: trunk/libs/unordered/test/unordered/erase_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/erase_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/erase_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -28,6 +28,8 @@
{
std::cerr<<"Erase by key.\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
for(BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator
@@ -44,6 +46,8 @@
std::cerr<<"erase(begin()).\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
@@ -64,6 +68,8 @@
std::cerr<<"erase(random position).\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
@@ -96,6 +102,8 @@
std::cerr<<"erase(ranges).\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(500, generator);
Container x(v.begin(), v.end());
@@ -118,6 +126,8 @@
std::cerr<<"quick_erase(begin()).\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
@@ -136,6 +146,8 @@
std::cerr<<"quick_erase(random position).\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
std::size_t size = x.size();
@@ -169,6 +181,8 @@
std::cerr<<"clear().\n";
{
+ test::check_instances check_;
+
test::random_values<Container> v(500, generator);
Container x(v.begin(), v.end());
x.clear();
Modified: trunk/libs/unordered/test/unordered/find_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/find_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/find_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -24,6 +24,8 @@
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
{
+ test::check_instances check_;
+
test::random_values<X> v(500, generator);
X x(v.begin(), v.end());
X const& x_const = x;
@@ -69,6 +71,8 @@
}
{
+ test::check_instances check_;
+
X x;
test::random_values<X> v2(5, generator);
Modified: trunk/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/insert_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -26,6 +26,8 @@
void unique_insert_tests1(X*,
test::random_generator generator = test::default_generator)
{
+ test::check_instances check_;
+
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef test::ordered<X> ordered;
@@ -65,6 +67,9 @@
{
std::cerr<<"insert(value) tests for containers with equivalent keys.\n";
+ test::check_instances check_;
+
+
X x;
test::ordered<X> tracker = test::create_ordered(x);
@@ -102,6 +107,8 @@
std::cerr<<"insert(begin(), value) tests.\n";
{
+ test::check_instances check_;
+
X x;
tracker_type tracker = test::create_ordered(x);
@@ -128,6 +135,8 @@
std::cerr<<"insert(end(), value) tests.\n";
{
+ test::check_instances check_;
+
X x;
X const& x_const = x;
tracker_type tracker = test::create_ordered(x);
@@ -155,6 +164,8 @@
std::cerr<<"insert(pos, value) tests.\n";
{
+ test::check_instances check_;
+
X x;
const_iterator pos = x.begin();
tracker_type tracker = test::create_ordered(x);
@@ -182,6 +193,8 @@
std::cerr<<"insert single item range tests.\n";
{
+ test::check_instances check_;
+
X x;
tracker_type tracker = test::create_ordered(x);
@@ -207,6 +220,8 @@
std::cerr<<"insert range tests.\n";
{
+ test::check_instances check_;
+
X x;
test::random_values<X> v(1000, generator);
@@ -219,6 +234,8 @@
std::cerr<<"insert input iterator range tests.\n";
{
+ test::check_instances check_;
+
X x;
test::random_values<X> v(1000, generator);
@@ -233,6 +250,8 @@
std::cerr<<"insert copy iterator range tests.\n";
{
+ test::check_instances check_;
+
X x;
test::random_values<X> v(1000, generator);
@@ -351,6 +370,8 @@
{
std::cerr<<"map_insert_range_test1\n";
+ test::check_instances check_;
+
typedef test::list<
std::pair<
BOOST_DEDUCED_TYPENAME X::key_type,
@@ -371,6 +392,8 @@
{
std::cerr<<"map_insert_range_test2\n";
+ test::check_instances check_;
+
typedef test::list<
std::pair<BOOST_DEDUCED_TYPENAME X::key_type const, test::implicitly_convertible>
> list;
Modified: trunk/libs/unordered/test/unordered/move_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/move_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/move_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -54,6 +54,8 @@
BOOST_DEDUCED_TYPENAME T::allocator_type al;
{
+ test::check_instances check_;
+
T y(empty(ptr));
BOOST_TEST(y.empty());
BOOST_TEST(test::equivalent(y.hash_function(), hf));
@@ -64,6 +66,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<T> v(1000, generator);
test::object_count count;
T y(create(v, count));
@@ -80,6 +84,8 @@
test::random_generator const& generator = test::default_generator)
{
{
+ test::check_instances check_;
+
test::random_values<T> v(500, generator);
test::object_count count;
T y;
@@ -104,6 +110,8 @@
test::object_count count;
{
+ test::check_instances check_;
+
test::random_values<T> v(500, generator);
T y(create(v, count, hf, eq, al, 0.5));
#if defined(BOOST_HAS_NRVO)
@@ -118,6 +126,8 @@
}
{
+ test::check_instances check_;
+
// TODO: To do this correctly requires the fancy new allocator
// stuff.
test::random_values<T> v(500, generator);
@@ -132,6 +142,8 @@
}
/*
{
+ test::check_instances check_;
+
test::random_values<T> v(25, generator);
T y(create(v, count, hf, eq, al, 1.0), al);
#if !defined(BOOST_NO_RVALUE_REFERENCES)
Modified: trunk/libs/unordered/test/unordered/swap_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/swap_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/swap_tests.cpp 2011-08-14 14:52:43 EDT (Sun, 14 Aug 2011)
@@ -37,16 +37,22 @@
void swap_tests1(X*, test::random_generator generator = test::default_generator)
{
{
+ test::check_instances check_;
+
X x;
swap_test_impl(x, x);
}
{
+ test::check_instances check_;
+
X x,y;
swap_test_impl(x, y);
}
{
+ test::check_instances check_;
+
test::random_values<X> v(1000, generator);
X x, y(v.begin(), v.end());
swap_test_impl(x, y);
@@ -54,6 +60,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<X> vx(1000, generator), vy(1000, generator);
X x(vx.begin(), vx.end()), y(vy.begin(), vy.end());
swap_test_impl(x, y);
@@ -72,12 +80,16 @@
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
{
+ test::check_instances check_;
+
X x(0, hasher(1), key_equal(1));
X y(0, hasher(2), key_equal(2));
swap_test_impl(x, y);
}
{
+ test::check_instances check_;
+
test::random_values<X> v(1000, generator);
X x(v.begin(), v.end(), 0, hasher(1), key_equal(1));
X y(0, hasher(2), key_equal(2));
@@ -85,6 +97,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<X> vx(100, generator), vy(50, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1));
X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2));
@@ -93,6 +107,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<X> vx(50, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(), key_equal(), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2));
@@ -100,6 +116,8 @@
}
{
+ test::check_instances check_;
+
test::random_values<X> vx(100, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1),
allocator_type(1));
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk