|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56562 - in trunk: boost/unordered/detail libs/unordered/test/unordered
From: daniel_james_at_[hidden]
Date: 2009-10-03 12:42:20
Author: danieljames
Date: 2009-10-03 12:42:20 EDT (Sat, 03 Oct 2009)
New Revision: 56562
URL: http://svn.boost.org/trac/boost/changeset/56562
Log:
Make sure inserting from a range of types other than the value type is better tested.
Text files modified:
trunk/boost/unordered/detail/unique.hpp | 7 +++----
trunk/libs/unordered/test/unordered/insert_tests.cpp | 27 ++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 7 deletions(-)
Modified: trunk/boost/unordered/detail/unique.hpp
==============================================================================
--- trunk/boost/unordered/detail/unique.hpp (original)
+++ trunk/boost/unordered/detail/unique.hpp 2009-10-03 12:42:20 EDT (Sat, 03 Oct 2009)
@@ -324,10 +324,9 @@
do {
// No side effects in this initial code
- // Note: can't use get_key as '*i' might not be value_type.
- // TODO: Check if std::pair has an appropriate constructor. If not
- // that might not be true.
- // TODO: Test this line better.
+ // Note: can't use get_key as '*i' might not be value_type - it could
+ // be a pair with first_types as key_type without const or a
+ // different second_type.
key_type const& k = extractor::extract(*i);
std::size_t hash_value = this->hash_function()(k);
bucket_ptr bucket = this->bucket_ptr_from_hash(hash_value);
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 2009-10-03 12:42:20 EDT (Sat, 03 Oct 2009)
@@ -313,10 +313,12 @@
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 @@
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,7 +383,12 @@
((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))
)
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