forked from boostorg/unordered
Improved support for Visual C++.
[SVN r2985]
This commit is contained in:
@@ -34,7 +34,7 @@ void assign_tests1(T* = 0)
|
||||
T x(v.begin(), v.end());
|
||||
|
||||
test::ordered<T> tracker = test::create_ordered(x);
|
||||
tracker.insert(v.begin(), v.end());
|
||||
tracker.insert_range(v.begin(), v.end());
|
||||
|
||||
x = x;
|
||||
tracker.compare(x);
|
||||
@@ -68,7 +68,7 @@ void assign_tests2(T* = 0)
|
||||
x2 = x1;
|
||||
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
||||
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
||||
check_container(x2, v);
|
||||
test::check_container(x2, v);
|
||||
}
|
||||
|
||||
std::cerr<<"assign_tests2.2\n";
|
||||
@@ -81,7 +81,7 @@ void assign_tests2(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x2.hash_function(), hf1));
|
||||
BOOST_TEST(test::equivalent(x2.key_eq(), eq1));
|
||||
BOOST_TEST(test::equivalent(x2.get_allocator(), al2));
|
||||
check_container(x2, v1);
|
||||
test::check_container(x2, v1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ void bucket_tests(X* = 0)
|
||||
|
||||
for(size_type i = 0; i < x.bucket_count(); ++i) {
|
||||
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.begin(i), x.end(i)));
|
||||
X const& x_ref(x);
|
||||
X const& x_ref = x;
|
||||
BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.begin(i), x_ref.end(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
X(10);
|
||||
X a3(10);
|
||||
X();
|
||||
X a4();
|
||||
X a4;
|
||||
|
||||
typename X::value_type* i = 0;
|
||||
typename X::value_type* j = 0;
|
||||
|
||||
@@ -67,7 +67,7 @@ void constructor_tests1(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 6\n";
|
||||
@@ -78,7 +78,7 @@ void constructor_tests1(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 7\n";
|
||||
@@ -89,7 +89,7 @@ void constructor_tests1(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 8\n";
|
||||
@@ -99,7 +99,7 @@ void constructor_tests1(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 9\n";
|
||||
@@ -120,7 +120,7 @@ void constructor_tests1(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ void constructor_tests2(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq1));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 4\n";
|
||||
@@ -174,7 +174,7 @@ void constructor_tests2(T* = 0)
|
||||
BOOST_TEST(test::equivalent(x.hash_function(), hf1));
|
||||
BOOST_TEST(test::equivalent(x.key_eq(), eq));
|
||||
BOOST_TEST(test::equivalent(x.get_allocator(), al));
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
}
|
||||
|
||||
|
||||
@@ -183,8 +183,8 @@ void constructor_tests2(T* = 0)
|
||||
test::random_values<T> v(100);
|
||||
T x(v.begin(), v.end(), 0, hf, eq, al1);
|
||||
T y(x.begin(), x.end(), 0, hf1, eq1, al2);
|
||||
check_container(x, v);
|
||||
check_container(y, x);
|
||||
test::check_container(x, v);
|
||||
test::check_container(y, x);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 6\n";
|
||||
@@ -192,8 +192,8 @@ void constructor_tests2(T* = 0)
|
||||
test::random_values<T> v(100);
|
||||
T x(v.begin(), v.end(), 0, hf1, eq1);
|
||||
T y(x.begin(), x.end(), 0, hf, eq);
|
||||
check_container(x, v);
|
||||
check_container(y, x);
|
||||
test::check_container(x, v);
|
||||
test::check_container(y, x);
|
||||
}
|
||||
|
||||
std::cerr<<"Construct 7\n";
|
||||
@@ -201,8 +201,8 @@ void constructor_tests2(T* = 0)
|
||||
test::random_values<T> v(100);
|
||||
T x(v.begin(), v.end(), 0, hf1, eq1);
|
||||
T y(x.begin(), x.end(), 0, hf2, eq2);
|
||||
check_container(x, v);
|
||||
check_container(y, x);
|
||||
test::check_container(x, v);
|
||||
test::check_container(y, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,20 @@
|
||||
template <class X>
|
||||
void find_tests1(X*)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
{
|
||||
test::random_values<X> v(500);
|
||||
X x(v.begin(), v.end());
|
||||
X const& x_const = x;
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
tracker.insert(v.begin(), v.end());
|
||||
tracker.insert_range(v.begin(), v.end());
|
||||
|
||||
for(typename test::ordered<X>::const_iterator it =
|
||||
tracker.begin(); it != tracker.end(); ++it)
|
||||
for(typename test::ordered<X>::const_iterator it1 =
|
||||
tracker.begin(); it1 != tracker.end(); ++it1)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it);
|
||||
typename X::iterator pos = x.find(key);
|
||||
typename X::key_type key = test::get_key<X>(*it1);
|
||||
iterator pos = x.find(key);
|
||||
typename X::const_iterator const_pos = x_const.find(key);
|
||||
BOOST_TEST(pos != x.end() &&
|
||||
x.key_eq()(key, test::get_key<X>(*pos)));
|
||||
@@ -43,17 +45,16 @@ void find_tests1(X*)
|
||||
}
|
||||
|
||||
test::random_values<X> v2(500);
|
||||
for(typename test::random_values<X>::const_iterator it =
|
||||
v2.begin(); it != v2.end(); ++it)
|
||||
for(typename test::random_values<X>::const_iterator it2 =
|
||||
v2.begin(); it2 != v2.end(); ++it2)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it);
|
||||
typename X::key_type key = test::get_key<X>(*it2);
|
||||
if(tracker.find(test::get_key<X>(key)) == tracker.end())
|
||||
{
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
BOOST_TEST(x_const.find(key) == x_const.end());
|
||||
BOOST_TEST(x.count(key) == 0);
|
||||
std::pair<typename X::iterator,
|
||||
typename X::iterator> range = x.equal_range(key);
|
||||
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||
BOOST_TEST(range.first == range.second);
|
||||
}
|
||||
}
|
||||
@@ -63,14 +64,13 @@ void find_tests1(X*)
|
||||
X x;
|
||||
|
||||
test::random_values<X> v2(5);
|
||||
for(typename test::random_values<X>::const_iterator it =
|
||||
v2.begin(); it != v2.end(); ++it)
|
||||
for(typename test::random_values<X>::const_iterator it3 =
|
||||
v2.begin(); it3 != v2.end(); ++it3)
|
||||
{
|
||||
typename X::key_type key = test::get_key<X>(*it);
|
||||
typename X::key_type key = test::get_key<X>(*it3);
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
BOOST_TEST(x.count(key) == 0);
|
||||
std::pair<typename X::iterator,
|
||||
typename X::iterator> range = x.equal_range(key);
|
||||
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||
BOOST_TEST(range.first == range.second);
|
||||
}
|
||||
}
|
||||
@@ -87,4 +87,6 @@ int main()
|
||||
find_tests1((boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
find_tests1((boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
find_tests1((boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >*) 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
template <class X>
|
||||
void unique_insert_tests1(X* = 0)
|
||||
{
|
||||
typedef typename X::iterator iterator;
|
||||
typedef test::ordered<X> ordered;
|
||||
typedef typename test::ordered<X>::iterator ordered_iterator;
|
||||
|
||||
std::cerr<<"insert(value) tests for containers with unique keys.\n";
|
||||
|
||||
X x;
|
||||
@@ -30,9 +34,8 @@ void unique_insert_tests1(X* = 0)
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
std::pair<typename X::iterator, bool> r1 = x.insert(*it);
|
||||
std::pair<typename test::ordered<X>::iterator, bool> r2
|
||||
= tracker.insert(*it);
|
||||
std::pair<iterator, bool> r1 = x.insert(*it);
|
||||
std::pair<ordered_iterator, bool> r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(r1.second == r2.second);
|
||||
BOOST_TEST(*r1.first == *r2.first);
|
||||
@@ -192,7 +195,7 @@ void insert_tests2(X* = 0)
|
||||
|
||||
test::random_values<X> v(1000);
|
||||
x.insert(v.begin(), v.end());
|
||||
check_container(x, v);
|
||||
test::check_container(x, v);
|
||||
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ void insert_test(X*, float mlf)
|
||||
template <class X>
|
||||
void load_factor_insert_tests(X* ptr = 0)
|
||||
{
|
||||
insert_test(ptr, 1.0);
|
||||
insert_test(ptr, 0.1);
|
||||
insert_test(ptr, 100);
|
||||
insert_test(ptr, 1.0f);
|
||||
insert_test(ptr, 0.1f);
|
||||
insert_test(ptr, 100.0f);
|
||||
|
||||
insert_test(ptr, (std::numeric_limits<float>::min)());
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ void rehash_test1(X* = 0)
|
||||
{
|
||||
test::random_values<X> v(1000);
|
||||
test::ordered<X> tracker;
|
||||
tracker.insert(v.begin(), v.end());
|
||||
tracker.insert_range(v.begin(), v.end());
|
||||
X x(v.begin(), v.end());
|
||||
|
||||
x.rehash(0); BOOST_TEST(postcondition(x, 0));
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
@@ -16,8 +19,8 @@ void swap_test_impl(X& x1, X& x2)
|
||||
{
|
||||
test::ordered<X> tracker1 = test::create_ordered(x1);
|
||||
test::ordered<X> tracker2 = test::create_ordered(x2);
|
||||
tracker1.insert(x1.begin(), x1.end());
|
||||
tracker2.insert(x2.begin(), x2.end());
|
||||
tracker1.insert_range(x1.begin(), x1.end());
|
||||
tracker2.insert_range(x2.begin(), x2.end());
|
||||
x1.swap(x2);
|
||||
tracker1.compare(x2);
|
||||
tracker2.compare(x1);
|
||||
|
||||
Reference in New Issue
Block a user