forked from boostorg/unordered
Merged revisions 42856-42881 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r42880 | danieljames | 2008-01-20 16:10:43 +0000 (Sun, 20 Jan 2008) | 17 lines Simplify the tests a little: Add a parameter to random_values to control what sort of values it generates. This means that instead of using equivalent_object to test collisions (which was a total hack) we now just need another parameter. This requires some meta programming to act differently for maps and sets. Because of this pairs no longer need to be generated so remove the code for doing that (which doesn't work on some compilers). Remove the generator object, just call generate directly. Remove some of the tests using int containers, they didn't really add to anthing other than the compile time (some tests are timing out). ........ [SVN r42882]
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
test::seed_t seed(356730);
|
||||
|
||||
template <class T>
|
||||
void constructor_tests1(T* = 0)
|
||||
void constructor_tests1(T*, test::random_generator generator = test::default_generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
@@ -68,7 +68,7 @@ void constructor_tests1(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 5\n";
|
||||
{
|
||||
test::random_values<T> v(1000);
|
||||
test::random_values<T> v(1000, generator);
|
||||
T x(v.begin(), v.end(), 10000, hf, eq);
|
||||
BOOST_TEST(x.bucket_count() >= 10000);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
@@ -80,7 +80,7 @@ void constructor_tests1(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 6\n";
|
||||
{
|
||||
test::random_values<T> v(10);
|
||||
test::random_values<T> v(10, generator);
|
||||
T x(v.begin(), v.end(), 10000, hf);
|
||||
BOOST_TEST(x.bucket_count() >= 10000);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
@@ -92,7 +92,7 @@ void constructor_tests1(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 7\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
test::random_values<T> v(100, generator);
|
||||
T x(v.begin(), v.end(), 100);
|
||||
BOOST_TEST(x.bucket_count() >= 100);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
@@ -104,7 +104,7 @@ void constructor_tests1(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 8\n";
|
||||
{
|
||||
test::random_values<T> v(1);
|
||||
test::random_values<T> v(1, generator);
|
||||
T x(v.begin(), v.end());
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
@@ -125,7 +125,7 @@ void constructor_tests1(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 10\n";
|
||||
{
|
||||
test::random_values<T> v(1000);
|
||||
test::random_values<T> v(1000, generator);
|
||||
T x(v.begin(), v.end(), 10000, hf, eq, al);
|
||||
BOOST_TEST(x.bucket_count() >= 10000);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
@@ -137,7 +137,7 @@ void constructor_tests1(T* = 0)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void constructor_tests2(T* = 0)
|
||||
void constructor_tests2(T*, test::random_generator const& generator = test::default_generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
||||
@@ -172,7 +172,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 3\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
test::random_values<T> v(100, generator);
|
||||
T x(v.begin(), v.end(), 0, hf1, eq1);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq1));
|
||||
@@ -183,7 +183,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 4\n";
|
||||
{
|
||||
test::random_values<T> v(5);
|
||||
test::random_values<T> v(5, generator);
|
||||
T x(v.begin(), v.end(), 1000, hf1);
|
||||
BOOST_TEST(x.bucket_count() >= 1000);
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||
@@ -196,7 +196,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 5\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
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);
|
||||
test::check_container(x, v);
|
||||
@@ -207,7 +207,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 6\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
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);
|
||||
test::check_container(x, v);
|
||||
@@ -218,7 +218,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 7\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
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);
|
||||
test::check_container(x, v);
|
||||
@@ -229,7 +229,7 @@ void constructor_tests2(T* = 0)
|
||||
|
||||
std::cerr<<"Construct 8 - from input iterator\n";
|
||||
{
|
||||
test::random_values<T> v(100);
|
||||
test::random_values<T> v(100, generator);
|
||||
T x(test::input_iterator(v.begin()), test::input_iterator(v.end()), 0, hf1, eq1);
|
||||
T y(test::input_iterator(x.begin()), test::input_iterator(x.end()), 0, hf2, eq2);
|
||||
test::check_container(x, v);
|
||||
@@ -257,55 +257,51 @@ void map_constructor_test(T* = 0)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cerr<<"Test1 unordered_set<int>\n";
|
||||
constructor_tests1((boost::unordered_set<int>*) 0);
|
||||
std::cerr<<"Test1 unordered_multiset<int>\n";
|
||||
constructor_tests1((boost::unordered_multiset<int>*) 0);
|
||||
std::cerr<<"Test1 unordered_map<int, int>\n";
|
||||
constructor_tests1((boost::unordered_map<int, int>*) 0);
|
||||
std::cerr<<"Test1 unordered_multimap<int, int>\n";
|
||||
constructor_tests1((boost::unordered_multimap<int, int>*) 0);
|
||||
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
||||
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
||||
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
||||
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
||||
|
||||
std::cerr<<"Test1 unordered_set<test::object>\n";
|
||||
constructor_tests1((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_multiset<test::object>\n";
|
||||
constructor_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_map<test::object, test::object>\n";
|
||||
constructor_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_multimap<test::object, test::object>\n";
|
||||
constructor_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test1 test_set\n";
|
||||
constructor_tests1(test_set);
|
||||
std::cerr<<"Test1 test_multiset\n";
|
||||
constructor_tests1(test_multiset);
|
||||
std::cerr<<"Test1 test_map\n";
|
||||
constructor_tests1(test_map);
|
||||
std::cerr<<"Test1 test_multimap\n";
|
||||
constructor_tests1(test_multimap);
|
||||
|
||||
std::cerr<<"Test1 unordered_set<test::equivalent_object>\n";
|
||||
constructor_tests1((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_multiset<test::equivalent_object>\n";
|
||||
constructor_tests1((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_map<test::equivalent_object, test::equivalent_object>\n";
|
||||
constructor_tests1((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test1 unordered_multimap<test::equivalent_object, test::equivalent_object>\n";
|
||||
constructor_tests1((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test1 test_set, collisions\n";
|
||||
constructor_tests1(test_set, test::generate_collisions);
|
||||
std::cerr<<"Test1 test_multiset, collisions\n";
|
||||
constructor_tests1(test_multiset, test::generate_collisions);
|
||||
std::cerr<<"Test1 test_map, collisions\n";
|
||||
constructor_tests1(test_map, test::generate_collisions);
|
||||
std::cerr<<"Test1 test_multimap, collisions\n";
|
||||
constructor_tests1(test_multimap, test::generate_collisions);
|
||||
|
||||
std::cerr<<"Test2 unordered_set<test::object>\n";
|
||||
constructor_tests2((boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_multiset<test::object>\n";
|
||||
constructor_tests2((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_map<test::object, test::object>\n";
|
||||
constructor_tests2((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_multimap<test::object, test::object>\n";
|
||||
constructor_tests2((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
std::cerr<<"Test2 test_set\n";
|
||||
constructor_tests2(test_set);
|
||||
std::cerr<<"Test2 test_multiset\n";
|
||||
constructor_tests2(test_multiset);
|
||||
std::cerr<<"Test2 test_map\n";
|
||||
constructor_tests2(test_map);
|
||||
std::cerr<<"Test2 test_multimap\n";
|
||||
constructor_tests2(test_multimap);
|
||||
|
||||
std::cerr<<"Test2 unordered_set<test::equivalent_object>\n";
|
||||
constructor_tests2((boost::unordered_set<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_multiset<test::equivalent_object>\n";
|
||||
constructor_tests2((boost::unordered_multiset<test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_map<test::equivalent_object, test::equivalent_object>\n";
|
||||
constructor_tests2((boost::unordered_map<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test2 unordered_multimap<test::equivalent_object, test::equivalent_object>\n";
|
||||
constructor_tests2((boost::unordered_multimap<test::equivalent_object, test::equivalent_object, test::hash, test::equal_to, test::allocator<test::equivalent_object> >*) 0);
|
||||
std::cerr<<"Test2 test_set, collisions\n";
|
||||
constructor_tests2(test_set, test::generate_collisions);
|
||||
std::cerr<<"Test2 test_multiset, collisions\n";
|
||||
constructor_tests2(test_multiset, test::generate_collisions);
|
||||
std::cerr<<"Test2 test_map, collisions\n";
|
||||
constructor_tests2(test_map, test::generate_collisions);
|
||||
std::cerr<<"Test2 test_multimap, collisions\n";
|
||||
constructor_tests2(test_multimap, test::generate_collisions);
|
||||
|
||||
std::cerr<<"Map Test unordered_map<test::object, test::object>\n";
|
||||
map_constructor_test((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
map_constructor_test(test_map);
|
||||
std::cerr<<"Map Test unordered_multimap<test::object, test::object>\n";
|
||||
map_constructor_test((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
map_constructor_test(test_multimap);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user