Merge unordred changes.

Merged revisions 56441,56461,56468,56557-56562 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r56441 | danieljames | 2009-09-27 20:12:04 +0100 (Sun, 27 Sep 2009) | 1 line
  
  Try supporting reference parameters in pairs. Probably not required.
........
  r56461 | danieljames | 2009-09-29 00:06:03 +0100 (Tue, 29 Sep 2009) | 1 line
  
  Remove the optimization for std::pair with a key reference. It'll be too much hassle to get a very unusual use case to work on all compilers.
........
  r56468 | danieljames | 2009-09-29 08:46:44 +0100 (Tue, 29 Sep 2009) | 1 line
  
  Just remove the test since the test itself doesn't work on most compilers.
........
  r56557 | danieljames | 2009-10-03 17:40:26 +0100 (Sat, 03 Oct 2009) | 1 line
  
  Fix the iterator category.
........
  r56558 | danieljames | 2009-10-03 17:40:53 +0100 (Sat, 03 Oct 2009) | 2 lines
  
  Update reference docs to latest version of draft standard and fill in
  some missing details.
........
  r56559 | danieljames | 2009-10-03 17:41:11 +0100 (Sat, 03 Oct 2009) | 1 line
  
  Stricter insert exception tests.
........
  r56560 | danieljames | 2009-10-03 17:41:32 +0100 (Sat, 03 Oct 2009) | 1 line
  
  Insert using initializer lists.
........
  r56561 | danieljames | 2009-10-03 17:42:00 +0100 (Sat, 03 Oct 2009) | 1 line
  
  Update the unordered rationale.
........
  r56562 | danieljames | 2009-10-03 17:42:20 +0100 (Sat, 03 Oct 2009) | 1 line
  
  Make sure inserting from a range of types other than the value type is better tested.
........


[SVN r56700]
This commit is contained in:
Daniel James committed 2009-10-10 13:52:53 +00:00
1 parent 1e7fe6a2d0
commit 3529bc00dc
11 files changed
+395 -140

No files matched your search

+7 -7
View File
@@ -31,7 +31,7 @@ struct insert_test_base : public test::exception_base
std::string scope(test::scope);
if(scope.find("hash::operator()") == std::string::npos)
strong.test(x);
strong.test(x, test::exception::detail::tracker.count_allocations);
test::check_equivalent_keys(x);
}
};
@@ -47,7 +47,7 @@ struct emplace_test1 : public insert_test_base<T>
for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
it = this->values.begin(), end = this->values.end(); it != end; ++it)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
x.emplace(*it);
}
}
@@ -64,7 +64,7 @@ struct insert_test1 : public insert_test_base<T>
for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
it = this->values.begin(), end = this->values.end(); it != end; ++it)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
x.insert(*it);
}
}
@@ -79,7 +79,7 @@ struct insert_test2 : public insert_test_base<T>
for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
it = this->values.begin(), end = this->values.end(); it != end; ++it)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
x.insert(x.begin(), *it);
}
}
@@ -106,7 +106,7 @@ struct insert_test4 : public insert_test_base<T>
for(BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
it = this->values.begin(), end = this->values.end(); it != end; ++it)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
x.insert(it, boost::next(it));
}
}
@@ -144,7 +144,7 @@ struct insert_test_rehash1 : public insert_test_base<T>
it = boost::next(this->values.begin(), x.size()), end = this->values.end();
it != end && count < 10; ++it, ++count)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
pos = x.insert(pos, *it);
}
@@ -167,7 +167,7 @@ struct insert_test_rehash2 : public insert_test_rehash1<T>
it = boost::next(this->values.begin(), x.size()), end = this->values.end();
it != end && count < 10; ++it, ++count)
{
strong.store(x);
strong.store(x, test::exception::detail::tracker.count_allocations);
x.insert(*it);
}
+6 -2
View File
@@ -20,18 +20,22 @@ namespace test
{
typedef test::list<BOOST_DEDUCED_TYPENAME X::value_type> values_type;
values_type values_;
unsigned int allocations_;
public:
void store(X const& x) {
void store(X const& x, unsigned int allocations = 0) {
DISABLE_EXCEPTIONS;
values_.clear();
values_.insert(x.cbegin(), x.cend());
allocations_ = allocations;
}
void test(X const& x) const {
void test(X const& x, unsigned int allocations = 0) const {
if(!(x.size() == values_.size() &&
std::equal(x.cbegin(), x.cend(), values_.begin(),
test::equivalent)))
BOOST_ERROR("Strong exception safety failure.");
if(allocations != allocations_)
BOOST_ERROR("Strong exception failure: extra allocations.");
}
};
}
+4
View File
@@ -93,6 +93,10 @@ namespace test
return x1.type_ != x2.type_;
}
};
std::size_t hash_value(test::object const& x) {
return hash()(x);
}
class less
{
+72 -3
View File
@@ -313,10 +313,12 @@ void map_tests(X*, test::random_generator generator = test::default_generator)
test::check_equivalent_keys(x);
}
// Some tests for when the range's value type doesn't match the container's value type.
template <class X>
void associative_insert_range_test(X*, test::random_generator generator = test::default_generator)
void map_insert_range_test1(X*, test::random_generator generator = test::default_generator)
{
std::cerr<<"associative_insert_range_test\n";
std::cerr<<"map_insert_range_test1\n";
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type, BOOST_DEDUCED_TYPENAME X::mapped_type> > list;
test::random_values<X> v(1000, generator);
@@ -327,6 +329,20 @@ void associative_insert_range_test(X*, test::random_generator generator = test::
test::check_equivalent_keys(x);
}
template <class X>
void map_insert_range_test2(X*, test::random_generator generator = test::default_generator)
{
std::cerr<<"map_insert_range_test2\n";
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type const, int> > list;
test::random_values<boost::unordered_map<BOOST_DEDUCED_TYPENAME X::key_type, int> > v(1000, generator);
list l(v.begin(), v.end());
X x; x.insert(l.begin(), l.end());
test::check_equivalent_keys(x);
}
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;
@@ -367,11 +383,64 @@ UNORDERED_TEST(map_tests,
((default_generator)(generate_collisions))
)
UNORDERED_TEST(associative_insert_range_test,
UNORDERED_TEST(map_insert_range_test1,
((test_map)(test_multimap))
((default_generator)(generate_collisions))
)
UNORDERED_TEST(map_insert_range_test2,
((test_map)(test_multimap))
((default_generator)(generate_collisions))
)
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
UNORDERED_AUTO_TEST(insert_initializer_list_set)
{
boost::unordered_set<int> set;
set.insert({1,2,3,1});
BOOST_TEST_EQ(set.size(), 3u);
BOOST_TEST(set.find(1) != set.end());
BOOST_TEST(set.find(4) == set.end());
}
UNORDERED_AUTO_TEST(insert_initializer_list_multiset)
{
boost::unordered_multiset<std::string> multiset;
multiset.insert({});
BOOST_TEST(multiset.empty());
multiset.insert({"a"});
BOOST_TEST_EQ(multiset.size(), 1u);
BOOST_TEST(multiset.find("a") != multiset.end());
BOOST_TEST(multiset.find("b") == multiset.end());
multiset.insert({"a","b"});
BOOST_TEST(multiset.size() == 3);
BOOST_TEST_EQ(multiset.count("a"), 2u);
BOOST_TEST_EQ(multiset.count("b"), 1u);
BOOST_TEST_EQ(multiset.count("c"), 0u);
}
UNORDERED_AUTO_TEST(insert_initializer_list_map)
{
boost::unordered_map<std::string, std::string> map;
map.insert({});
BOOST_TEST(map.empty());
map.insert({{"a", "b"},{"a", "b"},{"d", ""}});
BOOST_TEST_EQ(map.size(), 2u);
}
UNORDERED_AUTO_TEST(insert_initializer_list_multimap)
{
boost::unordered_multimap<std::string, std::string> multimap;
multimap.insert({});
BOOST_TEST(multimap.empty());
multimap.insert({{"a", "b"},{"a", "b"},{"d", ""}});
BOOST_TEST_EQ(multimap.size(), 3u);
BOOST_TEST_EQ(multimap.count("a"), 2u);
}
#endif
}
RUN_TESTS()