From 71096f4d2681773d8890113a0af23416f99bc0d4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 4 Jan 2010 22:49:39 +0000 Subject: [PATCH] Formatting changes, mostly to fit within 80 characters. Also, some C casts converted to static_cast. [SVN r58692] --- examples/fnv1.hpp | 9 +- include/boost/unordered/detail/fwd.hpp | 6 +- include/boost/unordered/detail/unique.hpp | 4 +- include/boost/unordered/unordered_map.hpp | 3 +- test/exception/assign_exception_tests.cpp | 12 +- .../exception/constructor_exception_tests.cpp | 16 ++- test/exception/erase_exception_tests.cpp | 3 +- test/exception/insert_exception_tests.cpp | 28 +++-- test/exception/rehash_exception_tests.cpp | 4 +- test/helpers/count.hpp | 11 +- test/helpers/equivalent.hpp | 8 +- test/helpers/exception_test.hpp | 88 ++++++++------ test/helpers/helpers.hpp | 6 +- test/helpers/invariants.hpp | 20 ++-- test/helpers/list.hpp | 29 ++++- test/helpers/memory.hpp | 26 +++-- test/helpers/prefix.hpp | 3 +- test/helpers/random_values.hpp | 4 +- test/helpers/test.hpp | 53 +++++---- test/helpers/tracker.hpp | 67 +++++++---- test/objects/minimal.hpp | 65 ++++++++--- test/objects/test.hpp | 40 +++++-- test/unordered/assign_tests.cpp | 22 +++- test/unordered/bucket_tests.cpp | 34 ++++-- test/unordered/compile_tests.hpp | 107 +++++++++++++----- test/unordered/constructor_tests.cpp | 38 +++++-- test/unordered/copy_tests.cpp | 22 +++- test/unordered/equality_tests.cpp | 51 +++++---- test/unordered/equivalent_keys_tests.cpp | 23 ++-- test/unordered/erase_equiv_tests.cpp | 3 +- test/unordered/erase_tests.cpp | 38 +++++-- test/unordered/find_tests.cpp | 25 ++-- test/unordered/fwd_set_test.cpp | 3 +- test/unordered/incomplete_test.cpp | 31 +++-- test/unordered/insert_stable_tests.cpp | 10 +- test/unordered/insert_tests.cpp | 95 +++++++++++----- test/unordered/load_factor_tests.cpp | 3 +- test/unordered/move_tests.cpp | 28 +++-- test/unordered/rehash_tests.cpp | 12 +- test/unordered/simple_tests.cpp | 3 +- test/unordered/swap_tests.cpp | 28 +++-- test/unordered/unnecessary_copy_tests.cpp | 40 ++++--- 42 files changed, 761 insertions(+), 360 deletions(-) diff --git a/examples/fnv1.hpp b/examples/fnv1.hpp index 03afc292..3337d136 100644 --- a/examples/fnv1.hpp +++ b/examples/fnv1.hpp @@ -55,11 +55,14 @@ namespace hash // For 128 bit machines: // const std::size_t fnv_prime = 309485009821345068724781401u; - // const std::size_t fnv_offset_basis = 275519064689413815358837431229664493455u; + // const std::size_t fnv_offset_basis = + // 275519064689413815358837431229664493455u; // For 256 bit machines: - // const std::size_t fnv_prime = 374144419156711147060143317175368453031918731002211u; - // const std::size_t fnv_offset_basis = 100029257958052580907070968620625704837092796014241193945225284501741471925557u; + // const std::size_t fnv_prime = + // 374144419156711147060143317175368453031918731002211u; + // const std::size_t fnv_offset_basis = + // 100029257958052580907070968620625704837092796014241193945225284501741471925557u; typedef basic_fnv_1 fnv_1; typedef basic_fnv_1a fnv_1a; diff --git a/include/boost/unordered/detail/fwd.hpp b/include/boost/unordered/detail/fwd.hpp index ab028710..1598cdb0 100644 --- a/include/boost/unordered/detail/fwd.hpp +++ b/include/boost/unordered/detail/fwd.hpp @@ -270,7 +270,8 @@ namespace boost { namespace unordered_detail { typedef BOOST_DEDUCED_TYPENAME A::value_type value_type; typedef BOOST_DEDUCED_TYPENAME iterator_base::node node; - typedef BOOST_DEDUCED_TYPENAME bucket::bucket_allocator bucket_allocator; + typedef BOOST_DEDUCED_TYPENAME bucket::bucket_allocator + bucket_allocator; typedef BOOST_DEDUCED_TYPENAME bucket::bucket_ptr bucket_ptr; typedef BOOST_DEDUCED_TYPENAME bucket::node_ptr node_ptr; @@ -973,7 +974,8 @@ namespace boost { namespace unordered_detail { typedef E extractor; typedef G group_type; - typedef hash_node_constructor node_constructor; + typedef hash_node_constructor + node_constructor; typedef hash_buckets buckets; typedef hash_buffered_functions buffered_functions; diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 79ba28e6..59920d00 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -323,8 +323,8 @@ namespace boost { namespace unordered_detail { do { // No side effects in this initial code - // 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 + // 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); diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 58ca3014..93e19789 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -291,7 +291,8 @@ namespace boost table_.emplace(v)); } - iterator emplace_hint(const_iterator, value_type const& v = value_type()) + iterator emplace_hint(const_iterator, + value_type const& v = value_type()) { return iterator(table_.emplace(v).first); } diff --git a/test/exception/assign_exception_tests.cpp b/test/exception/assign_exception_tests.cpp index bdb99c15..8e64efeb 100644 --- a/test/exception/assign_exception_tests.cpp +++ b/test/exception/assign_exception_tests.cpp @@ -47,10 +47,14 @@ struct assign_base : public test::exception_base typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal; typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type; - assign_base(unsigned int count1, unsigned int count2, int tag1, int tag2) - : x_values(count1), y_values(count2), - x(x_values.begin(), x_values.end(), 0, hasher(tag1), key_equal(tag1), allocator_type(tag1)), - y(y_values.begin(), y_values.end(), 0, hasher(tag2), key_equal(tag2), allocator_type(tag2)) {} + assign_base(unsigned int count1, unsigned int count2, int tag1, int tag2) : + x_values(count1), + y_values(count2), + x(x_values.begin(), x_values.end(), 0, hasher(tag1), key_equal(tag1), + allocator_type(tag1)), + y(y_values.begin(), y_values.end(), 0, hasher(tag2), key_equal(tag2), + allocator_type(tag2)) + {} typedef T data_type; T init() const { return T(x); } diff --git a/test/exception/constructor_exception_tests.cpp b/test/exception/constructor_exception_tests.cpp index 1b95af7d..ef3119e4 100644 --- a/test/exception/constructor_exception_tests.cpp +++ b/test/exception/constructor_exception_tests.cpp @@ -116,7 +116,8 @@ struct range_construct_test5 : public range, objects range_construct_test5() : range(60) {} void run() const { - T x(this->values.begin(), this->values.end(), 0, hash, equal_to, allocator); + T x(this->values.begin(), this->values.end(), 0, + hash, equal_to, allocator); } }; @@ -134,7 +135,16 @@ struct input_range_construct_test : public range, objects }; RUN_EXCEPTION_TESTS( - (construct_test1)(construct_test2)(construct_test3)(construct_test4)(construct_test5)(construct_test6) - (range_construct_test1)(range_construct_test2)(range_construct_test3)(range_construct_test4)(range_construct_test5) + (construct_test1) + (construct_test2) + (construct_test3) + (construct_test4) + (construct_test5) + (construct_test6) + (range_construct_test1) + (range_construct_test2) + (range_construct_test3) + (range_construct_test4) + (range_construct_test5) (input_range_construct_test), CONTAINER_SEQ) diff --git a/test/exception/erase_exception_tests.cpp b/test/exception/erase_exception_tests.cpp index 9718e9d3..f6eb5b42 100644 --- a/test/exception/erase_exception_tests.cpp +++ b/test/exception/erase_exception_tests.cpp @@ -40,7 +40,8 @@ struct erase_by_key_test1 : public erase_test_base { void run(T& x) const { - typedef BOOST_DEDUCED_TYPENAME test::random_values::const_iterator iterator; + typedef BOOST_DEDUCED_TYPENAME + test::random_values::const_iterator iterator; for(iterator it = this->values.begin(), end = this->values.end(); it != end; ++it) diff --git a/test/exception/insert_exception_tests.cpp b/test/exception/insert_exception_tests.cpp index 946fe036..85776241 100644 --- a/test/exception/insert_exception_tests.cpp +++ b/test/exception/insert_exception_tests.cpp @@ -28,7 +28,9 @@ struct insert_test_base : public test::exception_base return T(); } - void check BOOST_PREVENT_MACRO_SUBSTITUTION(T const& x, strong_type const& strong) const { + void check BOOST_PREVENT_MACRO_SUBSTITUTION( + T const& x, strong_type const& strong) const + { std::string scope(test::scope); if(scope.find("hash::operator()") == std::string::npos) @@ -46,7 +48,8 @@ struct emplace_test1 : public insert_test_base void run(T& x, strong_type& strong) const { for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = this->values.begin(), end = this->values.end(); it != end; ++it) + it = this->values.begin(), end = this->values.end(); + it != end; ++it) { strong.store(x, test::exception::detail::tracker.count_allocations); x.emplace(*it); @@ -63,7 +66,8 @@ struct insert_test1 : public insert_test_base void run(T& x, strong_type& strong) const { for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = this->values.begin(), end = this->values.end(); it != end; ++it) + it = this->values.begin(), end = this->values.end(); + it != end; ++it) { strong.store(x, test::exception::detail::tracker.count_allocations); x.insert(*it); @@ -78,7 +82,8 @@ struct insert_test2 : public insert_test_base void run(T& x, strong_type& strong) const { for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = this->values.begin(), end = this->values.end(); it != end; ++it) + it = this->values.begin(), end = this->values.end(); + it != end; ++it) { strong.store(x, test::exception::detail::tracker.count_allocations); x.insert(x.begin(), *it); @@ -105,7 +110,8 @@ struct insert_test4 : public insert_test_base void run(T& x, strong_type& strong) const { for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = this->values.begin(), end = this->values.end(); it != end; ++it) + it = this->values.begin(), end = this->values.end(); + it != end; ++it) { strong.store(x, test::exception::detail::tracker.count_allocations); x.insert(it, boost::next(it)); @@ -142,7 +148,8 @@ struct insert_test_rehash1 : public insert_test_base BOOST_DEDUCED_TYPENAME T::const_iterator pos = x.cbegin(); for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = boost::next(this->values.begin(), x.size()), end = this->values.end(); + it = boost::next(this->values.begin(), x.size()), + end = this->values.end(); it != end && count < 10; ++it, ++count) { strong.store(x, test::exception::detail::tracker.count_allocations); @@ -165,7 +172,8 @@ struct insert_test_rehash2 : public insert_test_rehash1 int count = 0; for(BOOST_DEDUCED_TYPENAME test::random_values::const_iterator - it = boost::next(this->values.begin(), x.size()), end = this->values.end(); + it = boost::next(this->values.begin(), x.size()), + end = this->values.end(); it != end && count < 10; ++it, ++count) { strong.store(x, test::exception::detail::tracker.count_allocations); @@ -181,7 +189,8 @@ struct insert_test_rehash2 : public insert_test_rehash1 template struct insert_test_rehash3 : public insert_test_base { - BOOST_DEDUCED_TYPENAME T::size_type mutable rehash_bucket_count, original_bucket_count; + BOOST_DEDUCED_TYPENAME T::size_type mutable + rehash_bucket_count, original_bucket_count; insert_test_rehash3() : insert_test_base(1000) {} @@ -196,7 +205,8 @@ struct insert_test_rehash3 : public insert_test_base rehash_bucket_count = static_cast( ceil(original_bucket_count * (double) x.max_load_factor())) - 1; - size_type initial_elements = rehash_bucket_count > 5 ? rehash_bucket_count - 5 : 1; + size_type initial_elements = + rehash_bucket_count > 5 ? rehash_bucket_count - 5 : 1; BOOST_TEST(initial_elements < this->values.size()); x.insert(this->values.begin(), diff --git a/test/exception/rehash_exception_tests.cpp b/test/exception/rehash_exception_tests.cpp index 03f49ce8..2de210f5 100644 --- a/test/exception/rehash_exception_tests.cpp +++ b/test/exception/rehash_exception_tests.cpp @@ -20,7 +20,9 @@ struct rehash_test_base : public test::exception_base { test::random_values values; unsigned int n; - rehash_test_base(unsigned int count = 100, unsigned int n = 0) : values(count), n(n) {} + rehash_test_base(unsigned int count = 100, unsigned int n = 0) + : values(count), n(n) + {} typedef T data_type; typedef test::strong strong_type; diff --git a/test/helpers/count.hpp b/test/helpers/count.hpp index 0589586e..ff2bb830 100644 --- a/test/helpers/count.hpp +++ b/test/helpers/count.hpp @@ -39,8 +39,15 @@ namespace test { return !(*this == x); } - friend std::ostream& operator<<(std::ostream& out, object_count const& c) { - out<<"[instances: "< - bool equivalent_impl(boost::hash const&, boost::hash const&, derived_type) { + bool equivalent_impl(boost::hash const&, boost::hash const&, + derived_type) + { return true; } template - bool equivalent_impl(std::equal_to const&, std::equal_to const&, derived_type) { + bool equivalent_impl(std::equal_to const&, std::equal_to const&, + derived_type) + { return true; } diff --git a/test/helpers/exception_test.hpp b/test/helpers/exception_test.hpp index a66c30aa..1e7ae248 100644 --- a/test/helpers/exception_test.hpp +++ b/test/helpers/exception_test.hpp @@ -12,44 +12,50 @@ #include #include -# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \ - UNORDERED_AUTO_TEST(name) \ - { \ - test_func< type > fixture; \ - ::test::lightweight::exception_safety(fixture, BOOST_STRINGIZE(test_func)); \ - } +# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \ + UNORDERED_AUTO_TEST(name) \ + { \ + test_func< type > fixture; \ + ::test::lightweight::exception_safety( \ + fixture, BOOST_STRINGIZE(test_func)); \ + } \ + # define UNORDERED_EPOINT_IMPL ::test::lightweight::epoint #define UNORDERED_EXCEPTION_TEST_POSTFIX RUN_TESTS() -#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \ - BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, (test_seq)(param_seq)) \ - RUN_TESTS() +#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \ + BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, \ + (test_seq)(param_seq)) \ + RUN_TESTS() \ -#define RUN_EXCEPTION_TESTS_OP(r, product) \ - UNORDERED_EXCEPTION_TEST_CASE( \ - BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, product), \ - BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(1, product)) \ - ), \ - BOOST_PP_SEQ_ELEM(0, product), \ - BOOST_PP_SEQ_ELEM(1, product) \ - ) +#define RUN_EXCEPTION_TESTS_OP(r, product) \ + UNORDERED_EXCEPTION_TEST_CASE( \ + BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, product), \ + BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(1, product)) \ + ), \ + BOOST_PP_SEQ_ELEM(0, product), \ + BOOST_PP_SEQ_ELEM(1, product) \ + ) \ -#define UNORDERED_SCOPE(scope_name) \ - for(::test::scope_guard unordered_test_guard( \ - BOOST_STRINGIZE(scope_name)); \ - !unordered_test_guard.dismissed(); \ - unordered_test_guard.dismiss()) +#define UNORDERED_SCOPE(scope_name) \ + for(::test::scope_guard unordered_test_guard( \ + BOOST_STRINGIZE(scope_name)); \ + !unordered_test_guard.dismissed(); \ + unordered_test_guard.dismiss()) \ -#define UNORDERED_EPOINT(name) \ - if(::test::exceptions_enabled) { \ - UNORDERED_EPOINT_IMPL(name); \ - } +#define UNORDERED_EPOINT(name) \ + if(::test::exceptions_enabled) { \ + UNORDERED_EPOINT_IMPL(name); \ + } \ -#define ENABLE_EXCEPTIONS \ - ::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(true) -#define DISABLE_EXCEPTIONS \ - ::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(false) +#define ENABLE_EXCEPTIONS \ + ::test::exceptions_enable BOOST_PP_CAT( \ + ENABLE_EXCEPTIONS_, __LINE__)(true) \ + +#define DISABLE_EXCEPTIONS \ + ::test::exceptions_enable BOOST_PP_CAT( \ + ENABLE_EXCEPTIONS_, __LINE__)(false) \ namespace test { static char const* scope = ""; @@ -114,21 +120,24 @@ namespace test { }; template - inline void call_ignore_extra_parameters(void (T::*fn)() const, T2 const& obj, + inline void call_ignore_extra_parameters( + void (T::*fn)() const, T2 const& obj, P1&, P2&) { (obj.*fn)(); } template - inline void call_ignore_extra_parameters(void (T::*fn)(P1&) const, T2 const& obj, + inline void call_ignore_extra_parameters( + void (T::*fn)(P1&) const, T2 const& obj, P1& p1, P2&) { (obj.*fn)(p1); } template - inline void call_ignore_extra_parameters(void (T::*fn)(P1&, P2&) const, T2 const& obj, + inline void call_ignore_extra_parameters( + void (T::*fn)(P1&, P2&) const, T2 const& obj, P1& p1, P2& p2) { (obj.*fn)(p1, p2); @@ -156,11 +165,18 @@ namespace test { strong.store(x); try { ENABLE_EXCEPTIONS; - call_ignore_extra_parameters(&Test::run, test_, x, strong); + call_ignore_extra_parameters< + Test, + BOOST_DEDUCED_TYPENAME Test::data_type, + BOOST_DEDUCED_TYPENAME Test::strong_type + >(&Test::run, test_, x, strong); } catch(...) { - call_ignore_extra_parameters(&Test::check, test_, - constant(x), constant(strong)); + call_ignore_extra_parameters< + Test, + BOOST_DEDUCED_TYPENAME Test::data_type const, + BOOST_DEDUCED_TYPENAME Test::strong_type const + >(&Test::check, test_, constant(x), constant(strong)); throw; } } diff --git a/test/helpers/helpers.hpp b/test/helpers/helpers.hpp index 79132c4d..2293f23f 100644 --- a/test/helpers/helpers.hpp +++ b/test/helpers/helpers.hpp @@ -19,13 +19,15 @@ namespace test } template - static key_type const& get_key(std::pair const& x, char = 0) + static key_type const& get_key( + std::pair const& x, char = 0) { return x.first; } template - static key_type const& get_key(std::pair const& x, unsigned char = 0) + static key_type const& get_key(std::pair const& x, + unsigned char = 0) { return x.first; } diff --git a/test/helpers/invariants.hpp b/test/helpers/invariants.hpp index 1e14d685..a83d76be 100644 --- a/test/helpers/invariants.hpp +++ b/test/helpers/invariants.hpp @@ -17,8 +17,9 @@ #if defined(BOOST_MSVC) #pragma warning(push) -#pragma warning(disable:4127) // conditional expression is constant -#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data +#pragma warning(disable:4127) // conditional expression is constant +#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', + // possible loss of data #endif namespace test @@ -30,9 +31,11 @@ namespace test typedef BOOST_DEDUCED_TYPENAME X::key_type key_type; // Boost.Test was reporting memory leaks for std::set on g++-3.3. // So I work around it by using malloc. - std::set, test::malloc_allocator > found_; + std::set, + test::malloc_allocator > found_; - BOOST_DEDUCED_TYPENAME X::const_iterator it = x1.begin(), end = x1.end(); + BOOST_DEDUCED_TYPENAME X::const_iterator + it = x1.begin(), end = x1.end(); BOOST_DEDUCED_TYPENAME X::size_type size = 0; while(it != end) { // First test that the current key has not occured before, required @@ -72,7 +75,8 @@ namespace test // // Check that the keys are in the correct bucket and are // // adjacent in the bucket. // BOOST_DEDUCED_TYPENAME X::size_type bucket = x1.bucket(key); - // BOOST_DEDUCED_TYPENAME X::const_local_iterator lit = x1.begin(bucket), lend = x1.end(bucket); + // BOOST_DEDUCED_TYPENAME X::const_local_iterator + // lit = x1.begin(bucket), lend = x1.end(bucket); // for(; lit != lend && !eq(get_key(*lit), key); ++lit) continue; // if(lit == lend) // BOOST_ERROR("Unable to find element with a local_iterator"); @@ -82,7 +86,8 @@ namespace test // BOOST_ERROR("Element count doesn't match local_iterator."); // for(; lit != lend; ++lit) { // if(eq(get_key(*lit), key)) { - // BOOST_ERROR("Non-adjacent element with equivalent key in bucket."); + // BOOST_ERROR("Non-adjacent element with equivalent key " + // "in bucket."); // break; // } // } @@ -91,7 +96,8 @@ namespace test // Finally, check that size matches up. if(x1.size() != size) BOOST_ERROR("x1.size() doesn't match actual size."); - float load_factor = static_cast(size) / static_cast(x1.bucket_count()); + float load_factor = + static_cast(size) / static_cast(x1.bucket_count()); using namespace std; if(fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64) BOOST_ERROR("x1.load_factor() doesn't match actual load_factor."); diff --git a/test/helpers/list.hpp b/test/helpers/list.hpp index 3b59ce3e..ebb37b8f 100644 --- a/test/helpers/list.hpp +++ b/test/helpers/list.hpp @@ -126,12 +126,29 @@ namespace test T const& operator*() const { return ptr_->value_; } T const* operator->() const { return &ptr_->value_; } - list_const_iterator& operator++() { - ptr_ = ptr_->next_; return *this; } - list_const_iterator operator++(int) { - list_const_iterator tmp = *this; ptr_ = ptr_->next_; return tmp; } - bool operator==(const_iterator y) const { return ptr_ == y.ptr_; } - bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; } + + list_const_iterator& operator++() + { + ptr_ = ptr_->next_; + return *this; + } + + list_const_iterator operator++(int) + { + list_const_iterator tmp = *this; + ptr_ = ptr_->next_; + return tmp; + } + + bool operator==(const_iterator y) const + { + return ptr_ == y.ptr_; + } + + bool operator!=(const_iterator y) const + { + return ptr_ != y.ptr_; + } }; } diff --git a/test/helpers/memory.hpp b/test/helpers/memory.hpp index 6dbec85f..84c1787b 100644 --- a/test/helpers/memory.hpp +++ b/test/helpers/memory.hpp @@ -62,7 +62,8 @@ namespace test #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG) template <> struct allocator_memory_type_gen { - typedef std::map type; + typedef std::map + type; }; #endif @@ -73,7 +74,8 @@ namespace test std::pair >::type allocator_type; - typedef BOOST_DEDUCED_TYPENAME allocator_memory_type_gen::type + typedef BOOST_DEDUCED_TYPENAME + allocator_memory_type_gen::type allocated_memory_type; allocated_memory_type allocated_memory; @@ -106,7 +108,8 @@ namespace test bool no_constructions_left = (count_constructions == 0); bool allocated_memory_empty = allocated_memory.empty(); - // Clearing the data before the checks terminate the tests. + // Clearing the data before the checks terminate the + // tests. count_allocations = 0; count_constructions = 0; allocated_memory.clear(); @@ -118,7 +121,8 @@ namespace test } } - void track_allocate(void *ptr, std::size_t n, std::size_t size, int tag) + void track_allocate(void *ptr, std::size_t n, std::size_t size, + int tag) { if(n == 0) { BOOST_ERROR("Allocating 0 length array."); @@ -132,10 +136,12 @@ namespace test } } - void track_deallocate(void* ptr, std::size_t n, std::size_t size, int tag) + void track_deallocate(void* ptr, std::size_t n, std::size_t size, + int tag) { - BOOST_DEDUCED_TYPENAME allocated_memory_type::iterator pos - = allocated_memory.find(memory_area(ptr, (char*) ptr + n * size)); + BOOST_DEDUCED_TYPENAME allocated_memory_type::iterator pos = + allocated_memory.find( + memory_area(ptr, (char*) ptr + n * size)); if(pos == allocated_memory.end()) { BOOST_ERROR("Deallocating unknown pointer."); } else { @@ -148,12 +154,14 @@ namespace test if(count_allocations > 0) --count_allocations; } - void track_construct(void* /*ptr*/, std::size_t /*size*/, int /*tag*/) + void track_construct(void* /*ptr*/, std::size_t /*size*/, + int /*tag*/) { ++count_constructions; } - void track_destroy(void* /*ptr*/, std::size_t /*size*/, int /*tag*/) + void track_destroy(void* /*ptr*/, std::size_t /*size*/, + int /*tag*/) { BOOST_TEST(count_constructions > 0); if(count_constructions > 0) --count_constructions; diff --git a/test/helpers/prefix.hpp b/test/helpers/prefix.hpp index 36080e46..ef879fb7 100644 --- a/test/helpers/prefix.hpp +++ b/test/helpers/prefix.hpp @@ -6,5 +6,6 @@ #if defined(_WIN32_WCE) // The standard windows mobile headers trigger this warning so I disable it // before doing anything else. -#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union +#pragma warning(disable:4201) // nonstandard extension used : + // nameless struct/union #endif diff --git a/test/helpers/random_values.hpp b/test/helpers/random_values.hpp index 0d71ea1d..85d22c7a 100644 --- a/test/helpers/random_values.hpp +++ b/test/helpers/random_values.hpp @@ -71,7 +71,9 @@ namespace test type_ == generate_collisions ? generate(int_ptr) % 10 : 1; count; --count) { - x.push_back(std::pair(key, generate(mapped_ptr))); + x.push_back( + std::pair( + key, generate(mapped_ptr))); } } } diff --git a/test/helpers/test.hpp b/test/helpers/test.hpp index 40b642b6..54c75614 100644 --- a/test/helpers/test.hpp +++ b/test/helpers/test.hpp @@ -11,19 +11,20 @@ #include #include -#define UNORDERED_AUTO_TEST(x) \ - struct BOOST_PP_CAT(x, _type) : public ::test::registered_test_base { \ - BOOST_PP_CAT(x, _type)() \ - : ::test::registered_test_base(BOOST_PP_STRINGIZE(x)) \ - { \ - ::test::test_list::add_test(this); \ - } \ - void run(); \ - }; \ - BOOST_PP_CAT(x, _type) x; \ - void BOOST_PP_CAT(x, _type)::run() -#define RUN_TESTS() int main(int, char**) \ - { ::test::test_list::run_tests(); return boost::report_errors(); } +#define UNORDERED_AUTO_TEST(x) \ + struct BOOST_PP_CAT(x, _type) : public ::test::registered_test_base { \ + BOOST_PP_CAT(x, _type)() \ + : ::test::registered_test_base(BOOST_PP_STRINGIZE(x)) \ + { \ + ::test::test_list::add_test(this); \ + } \ + void run(); \ + }; \ + BOOST_PP_CAT(x, _type) x; \ + void BOOST_PP_CAT(x, _type)::run() \ + +#define RUN_TESTS() int main(int, char**) \ + { ::test::test_list::run_tests(); return boost::report_errors(); } \ namespace test { struct registered_test_base { @@ -74,20 +75,22 @@ namespace test { #include // Run test with every combination of the parameters (a sequence of sequences) -#define UNORDERED_TEST(name, parameters) \ - BOOST_PP_SEQ_FOR_EACH_PRODUCT(UNORDERED_TEST_OP, ((name)) parameters) +#define UNORDERED_TEST(name, parameters) \ + BOOST_PP_SEQ_FOR_EACH_PRODUCT(UNORDERED_TEST_OP, ((name)) parameters) \ -#define UNORDERED_TEST_OP(r, product) \ - UNORDERED_TEST_OP2( \ - BOOST_PP_SEQ_HEAD(product), \ - BOOST_PP_SEQ_TAIL(product)) +#define UNORDERED_TEST_OP(r, product) \ + UNORDERED_TEST_OP2( \ + BOOST_PP_SEQ_HEAD(product), \ + BOOST_PP_SEQ_TAIL(product)) \ -#define UNORDERED_TEST_OP2(name, params) \ - UNORDERED_AUTO_TEST(BOOST_PP_SEQ_FOLD_LEFT(UNORDERED_TEST_OP_JOIN, name, params)) { \ - name BOOST_PP_SEQ_TO_TUPLE(params); \ - } +#define UNORDERED_TEST_OP2(name, params) \ + UNORDERED_AUTO_TEST( \ + BOOST_PP_SEQ_FOLD_LEFT(UNORDERED_TEST_OP_JOIN, name, params)) \ + { \ + name BOOST_PP_SEQ_TO_TUPLE(params); \ + } \ -#define UNORDERED_TEST_OP_JOIN(s, state, elem) \ - BOOST_PP_CAT(state, BOOST_PP_CAT(_, elem)) +#define UNORDERED_TEST_OP_JOIN(s, state, elem) \ + BOOST_PP_CAT(state, BOOST_PP_CAT(_, elem)) \ #endif diff --git a/test/helpers/tracker.hpp b/test/helpers/tracker.hpp index b5bf3c22..bf56b356 100644 --- a/test/helpers/tracker.hpp +++ b/test/helpers/tracker.hpp @@ -27,7 +27,8 @@ namespace test { template struct equals_to_compare2 - : public boost::mpl::identity > + : public boost::mpl::identity< + std::less > { }; @@ -62,37 +63,55 @@ namespace test values1.sort(); values2.sort(); BOOST_TEST(values1.size() == values2.size() && - test::equal(values1.begin(), values1.end(), values2.begin(), test::equivalent)); + test::equal(values1.begin(), values1.end(), + values2.begin(), test::equivalent)); } template - struct ordered_set - : public boost::mpl::if_< + struct ordered_set : public + boost::mpl::if_< test::has_unique_keys, - std::set::type>, - std::multiset::type> - > {}; + std::set< + BOOST_DEDUCED_TYPENAME X::value_type, + BOOST_DEDUCED_TYPENAME equals_to_compare< + BOOST_DEDUCED_TYPENAME X::key_equal + >::type + >, + std::multiset< + BOOST_DEDUCED_TYPENAME X::value_type, + BOOST_DEDUCED_TYPENAME equals_to_compare< + BOOST_DEDUCED_TYPENAME X::key_equal + >::type + > + > {}; template - struct ordered_map - : public boost::mpl::if_< + struct ordered_map : public + boost::mpl::if_< test::has_unique_keys, - std::map::type>, - std::multimap::type> - > {}; + std::map< + BOOST_DEDUCED_TYPENAME X::key_type, + BOOST_DEDUCED_TYPENAME X::mapped_type, + BOOST_DEDUCED_TYPENAME equals_to_compare< + BOOST_DEDUCED_TYPENAME X::key_equal + >::type + >, + std::multimap< + BOOST_DEDUCED_TYPENAME X::key_type, + BOOST_DEDUCED_TYPENAME X::mapped_type, + BOOST_DEDUCED_TYPENAME equals_to_compare< + BOOST_DEDUCED_TYPENAME X::key_equal + >::type + > + > {}; template - struct ordered_base - : public boost::mpl::eval_if< + struct ordered_base : public + boost::mpl::eval_if< test::is_set, test::ordered_set, - test::ordered_map > - { - }; + test::ordered_map + > {}; template class ordered : public ordered_base::type @@ -114,7 +133,8 @@ namespace test compare_range(x, *this); } - void compare_key(X const& x, BOOST_DEDUCED_TYPENAME X::value_type const& val) + void compare_key(X const& x, + BOOST_DEDUCED_TYPENAME X::value_type const& val) { compare_pairs( x.equal_range(get_key(val)), @@ -132,7 +152,8 @@ namespace test }; template - BOOST_DEDUCED_TYPENAME equals_to_compare::type create_compare(Equals const&) + BOOST_DEDUCED_TYPENAME + equals_to_compare::type create_compare(Equals const&) { BOOST_DEDUCED_TYPENAME equals_to_compare::type x; return x; diff --git a/test/objects/minimal.hpp b/test/objects/minimal.hpp index 252e3564..4f8680fb 100644 --- a/test/objects/minimal.hpp +++ b/test/objects/minimal.hpp @@ -46,31 +46,61 @@ namespace minimal class copy_constructible_equality_comparable { public: - static copy_constructible_equality_comparable create() { return copy_constructible_equality_comparable(); } - copy_constructible_equality_comparable(copy_constructible_equality_comparable const&) {} - ~copy_constructible_equality_comparable() {} + static copy_constructible_equality_comparable create() { + return copy_constructible_equality_comparable(); + } + + copy_constructible_equality_comparable( + copy_constructible_equality_comparable const&) + { + } + + ~copy_constructible_equality_comparable() + { + } + private: - copy_constructible_equality_comparable& operator=(copy_constructible_equality_comparable const&); + copy_constructible_equality_comparable& operator=( + copy_constructible_equality_comparable const&); copy_constructible_equality_comparable() {} }; - bool operator==(copy_constructible_equality_comparable, copy_constructible_equality_comparable) { + bool operator==( + copy_constructible_equality_comparable, + copy_constructible_equality_comparable) + { return true; } - bool operator!=(copy_constructible_equality_comparable, copy_constructible_equality_comparable) { + bool operator!=( + copy_constructible_equality_comparable, + copy_constructible_equality_comparable) + { return false; } class default_copy_constructible { public: - static default_copy_constructible create() { return default_copy_constructible(); } - default_copy_constructible() {} - default_copy_constructible(default_copy_constructible const&) {} - ~default_copy_constructible() {} + static default_copy_constructible create() + { + return default_copy_constructible(); + } + + default_copy_constructible() + { + } + + default_copy_constructible(default_copy_constructible const&) + { + } + + ~default_copy_constructible() + { + } private: - default_copy_constructible& operator=(default_copy_constructible const&); + default_copy_constructible& operator=( + default_copy_constructible const&); }; class assignable @@ -130,7 +160,8 @@ namespace minimal ptr& operator++() { ++ptr_; return *this; } ptr operator++(int) { ptr tmp(*this); ++ptr_; return tmp; } ptr operator+(std::ptrdiff_t s) const { return ptr(ptr_ + s); } - friend ptr operator+(std::ptrdiff_t s, ptr p) { return ptr(s + p.ptr_); } + friend ptr operator+(std::ptrdiff_t s, ptr p) + { return ptr(s + p.ptr_); } T& operator[](std::ptrdiff_t s) const { return ptr_[s]; } bool operator!() const { return !ptr_; } @@ -169,8 +200,10 @@ namespace minimal T const* operator->() const { return ptr_; } const_ptr& operator++() { ++ptr_; return *this; } const_ptr operator++(int) { const_ptr tmp(*this); ++ptr_; return tmp; } - const_ptr operator+(std::ptrdiff_t s) const { return const_ptr(ptr_ + s); } - friend const_ptr operator+(std::ptrdiff_t s, const_ptr p) { return ptr(s + p.ptr_); } + const_ptr operator+(std::ptrdiff_t s) const + { return const_ptr(ptr_ + s); } + friend const_ptr operator+(std::ptrdiff_t s, const_ptr p) + { return ptr(s + p.ptr_); } T const& operator[](int s) const { return ptr_[s]; } bool operator!() const { return !ptr_; } operator bool() const { return !!ptr_; } @@ -272,7 +305,9 @@ namespace boost { namespace test { namespace minimal { #endif - std::size_t hash_value(test::minimal::copy_constructible_equality_comparable) { + std::size_t hash_value( + test::minimal::copy_constructible_equality_comparable) + { return 1; } #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) diff --git a/test/objects/test.hpp b/test/objects/test.hpp index 767dbb4a..bfada4d2 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -190,13 +190,37 @@ namespace test template struct rebind { typedef allocator other; }; - explicit allocator(int t = 0) : tag_(t) { detail::tracker.allocator_ref(); } - template allocator(allocator const& x) : tag_(x.tag_) { detail::tracker.allocator_ref(); } - allocator(allocator const& x) : tag_(x.tag_) { detail::tracker.allocator_ref(); } - ~allocator() { detail::tracker.allocator_unref(); } + explicit allocator(int t = 0) : tag_(t) + { + detail::tracker.allocator_ref(); + } + + template allocator(allocator const& x) + : tag_(x.tag_) + { + detail::tracker.allocator_ref(); + } - pointer address(reference r) { return pointer(&r); } - const_pointer address(const_reference r) { return const_pointer(&r); } + allocator(allocator const& x) + : tag_(x.tag_) + { + detail::tracker.allocator_ref(); + } + + ~allocator() + { + detail::tracker.allocator_unref(); + } + + pointer address(reference r) + { + return pointer(&r); + } + + const_pointer address(const_reference r) + { + return const_pointer(&r); + } pointer allocate(size_type n) { pointer ptr(static_cast(::operator new(n * sizeof(T)))); @@ -250,7 +274,9 @@ namespace test }; template - bool equivalent_impl(allocator const& x, allocator const& y, test::derived_type) { + bool equivalent_impl(allocator const& x, allocator const& y, + test::derived_type) + { return x == y; } diff --git a/test/unordered/assign_tests.cpp b/test/unordered/assign_tests.cpp index 72a73fe7..3d5d4a14 100644 --- a/test/unordered/assign_tests.cpp +++ b/test/unordered/assign_tests.cpp @@ -20,7 +20,8 @@ namespace assign_tests { test::seed_t seed(96785); template -void assign_tests1(T*, test::random_generator generator = test::default_generator) +void assign_tests1(T*, + test::random_generator generator = test::default_generator) { BOOST_DEDUCED_TYPENAME T::hasher hf; BOOST_DEDUCED_TYPENAME T::key_equal eq; @@ -54,7 +55,8 @@ void assign_tests1(T*, test::random_generator generator = test::default_generato } template -void assign_tests2(T*, test::random_generator generator = test::default_generator) +void assign_tests2(T*, + test::random_generator generator = test::default_generator) { BOOST_DEDUCED_TYPENAME T::hasher hf1(1); BOOST_DEDUCED_TYPENAME T::hasher hf2(2); @@ -87,10 +89,18 @@ void assign_tests2(T*, test::random_generator generator = test::default_generato } } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/bucket_tests.cpp b/test/unordered/bucket_tests.cpp index 7126b8bb..c87dad84 100644 --- a/test/unordered/bucket_tests.cpp +++ b/test/unordered/bucket_tests.cpp @@ -43,24 +43,40 @@ void tests(X* = 0, test::random_generator generator = test::default_generator) if(bucket < x.max_bucket_count()) { // lit? lend?? I need a new naming scheme. const_local_iterator lit = x.begin(bucket), lend = x.end(bucket); - while(lit != lend && test::get_key(*it) != test::get_key(*lit)) ++lit; + while(lit != lend + && test::get_key(*it) != test::get_key(*lit)) + { + ++lit; + } BOOST_TEST(lit != lend); } } 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))); - BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.cbegin(i), x.cend(i))); + BOOST_TEST(x.bucket_size(i) == static_cast( + std::distance(x.begin(i), x.end(i)))); + BOOST_TEST(x.bucket_size(i) == static_cast( + std::distance(x.cbegin(i), x.cend(i)))); X const& x_ref = x; - BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.begin(i), x_ref.end(i))); - BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.cbegin(i), x_ref.cend(i))); + BOOST_TEST(x.bucket_size(i) == static_cast( + std::distance(x_ref.begin(i), x_ref.end(i)))); + BOOST_TEST(x.bucket_size(i) == static_cast( + std::distance(x_ref.cbegin(i), x_ref.cend(i)))); } } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; UNORDERED_TEST(tests, ((test_set)(test_multiset)(test_map)(test_multimap))) diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index aa33ee35..2def5318 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -37,10 +37,15 @@ void container_test(X& r, T const&) typedef BOOST_DEDUCED_TYPENAME X::difference_type difference_type; typedef BOOST_DEDUCED_TYPENAME X::size_type size_type; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_value::type iterator_value_type; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_value::type const_iterator_value_type; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type iterator_difference_type; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type const_iterator_difference_type; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_value::type iterator_value_type; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_value::type const_iterator_value_type; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type iterator_difference_type; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type + const_iterator_difference_type; typedef BOOST_DEDUCED_TYPENAME X::value_type value_type; typedef BOOST_DEDUCED_TYPENAME X::reference reference; @@ -149,7 +154,8 @@ void unordered_map_test(X& r, Key const& k, T const& v) { typedef BOOST_DEDUCED_TYPENAME X::value_type value_type; typedef BOOST_DEDUCED_TYPENAME X::key_type key_type; - BOOST_MPL_ASSERT((boost::is_same >)); + BOOST_MPL_ASSERT(( + boost::is_same >)); r.insert(std::pair(k, v)); @@ -212,25 +218,57 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq) typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator; typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator; - typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY::type iterator_category; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type iterator_difference; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer::type iterator_pointer; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference::type iterator_reference; + typedef BOOST_DEDUCED_TYPENAME + boost::BOOST_ITERATOR_CATEGORY::type + iterator_category; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type + iterator_difference; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_reference::type + iterator_reference; - typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY::type local_iterator_category; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type local_iterator_difference; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer::type local_iterator_pointer; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference::type local_iterator_reference; + typedef BOOST_DEDUCED_TYPENAME + boost::BOOST_ITERATOR_CATEGORY::type + local_iterator_category; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type + local_iterator_difference; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + local_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_reference::type + local_iterator_reference; - typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY::type const_iterator_category; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type const_iterator_difference; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer::type const_iterator_pointer; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference::type const_iterator_reference; + typedef BOOST_DEDUCED_TYPENAME + boost::BOOST_ITERATOR_CATEGORY::type + const_iterator_category; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type + const_iterator_difference; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_reference::type + const_iterator_reference; - typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY::type const_local_iterator_category; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference::type const_local_iterator_difference; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer::type const_local_iterator_pointer; - typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference::type const_local_iterator_reference; + typedef BOOST_DEDUCED_TYPENAME + boost::BOOST_ITERATOR_CATEGORY::type + const_local_iterator_category; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_difference::type + const_local_iterator_difference; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_local_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_reference::type + const_local_iterator_reference; BOOST_MPL_ASSERT((boost::is_same)); boost::function_requires >(); @@ -243,16 +281,25 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq) test::check_return_type::convertible(eq(k, k)); boost::function_requires >(); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); - boost::function_requires >(); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); - BOOST_MPL_ASSERT((boost::is_same)); + boost::function_requires< + boost::InputIteratorConcept >(); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); X(10, hf, eq); X a(10, hf, eq); diff --git a/test/unordered/constructor_tests.cpp b/test/unordered/constructor_tests.cpp index 5ad411f0..b157bdbd 100644 --- a/test/unordered/constructor_tests.cpp +++ b/test/unordered/constructor_tests.cpp @@ -22,7 +22,8 @@ namespace constructor_tests { test::seed_t seed(356730); template -void constructor_tests1(T*, test::random_generator generator = test::default_generator) +void constructor_tests1(T*, + test::random_generator generator = test::default_generator) { BOOST_DEDUCED_TYPENAME T::hasher hf; BOOST_DEDUCED_TYPENAME T::key_equal eq; @@ -152,7 +153,8 @@ void constructor_tests1(T*, test::random_generator generator = test::default_gen } template -void constructor_tests2(T*, test::random_generator const& generator = test::default_generator) +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); @@ -247,10 +249,12 @@ void constructor_tests2(T*, test::random_generator const& generator = test::defa test::random_values v(100, generator); BOOST_DEDUCED_TYPENAME test::random_values::const_iterator v_begin = v.begin(), v_end = v.end(); - T x(test::input_iterator(v_begin), test::input_iterator(v_end), 0, hf1, eq1); + T x(test::input_iterator(v_begin), + test::input_iterator(v_end), 0, hf1, eq1); BOOST_DEDUCED_TYPENAME T::const_iterator x_begin = x.begin(), x_end = x.end(); - T y(test::input_iterator(x_begin), test::input_iterator(x_end), 0, hf2, eq2); + T y(test::input_iterator(x_begin), + test::input_iterator(x_end), 0, hf2, eq2); test::check_container(x, v); test::check_container(y, x); test::check_equivalent_keys(x); @@ -325,11 +329,17 @@ void constructor_tests2(T*, test::random_generator const& generator = test::defa } template -void map_constructor_test(T* = 0, test::random_generator const& generator = test::default_generator) +void map_constructor_test(T* = 0, + test::random_generator const& generator = test::default_generator) { std::cerr<<"map_constructor_test\n"; - typedef test::list > list; + typedef test::list< + std::pair< + BOOST_DEDUCED_TYPENAME T::key_type, + BOOST_DEDUCED_TYPENAME T::mapped_type + > + > list; test::random_values v(1000, generator); list l(v.begin(), v.end()); T x(l.begin(), l.end()); @@ -338,10 +348,18 @@ void map_constructor_test(T* = 0, test::random_generator const& generator = test test::check_equivalent_keys(x); } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/copy_tests.cpp b/test/unordered/copy_tests.cpp index 8ddfb782..d939d0ff 100644 --- a/test/unordered/copy_tests.cpp +++ b/test/unordered/copy_tests.cpp @@ -20,7 +20,8 @@ namespace copy_tests { template -void copy_construct_tests1(T*, test::random_generator const& generator = test::default_generator) +void copy_construct_tests1(T*, + test::random_generator const& generator = test::default_generator) { BOOST_DEDUCED_TYPENAME T::hasher hf; BOOST_DEDUCED_TYPENAME T::key_equal eq; @@ -65,7 +66,8 @@ void copy_construct_tests1(T*, test::random_generator const& generator = test::d } template -void copy_construct_tests2(T* ptr, test::random_generator const& generator = test::default_generator) +void copy_construct_tests2(T* ptr, + test::random_generator const& generator = test::default_generator) { copy_construct_tests1(ptr); @@ -119,10 +121,18 @@ void copy_construct_tests2(T* ptr, test::random_generator const& generator = tes } } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/equality_tests.cpp b/test/unordered/equality_tests.cpp index 45c4c9d3..6d9541b6 100644 --- a/test/unordered/equality_tests.cpp +++ b/test/unordered/equality_tests.cpp @@ -30,36 +30,39 @@ namespace equality_tests } }; -#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \ - { \ - boost::unordered_set set1, set2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ - BOOST_TEST(set1 op set2); \ +#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \ + { \ + boost::unordered_set set1, set2; \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ + BOOST_TEST(set1 op set2); \ } -#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \ - { \ - boost::unordered_multiset set1, set2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ - BOOST_TEST(set1 op set2); \ +#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \ + { \ + boost::unordered_multiset \ + set1, set2; \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ + BOOST_TEST(set1 op set2); \ } -#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \ - { \ - boost::unordered_map map1, map2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ - BOOST_TEST(map1 op map2); \ +#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \ + { \ + boost::unordered_map \ + map1, map2; \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ + BOOST_TEST(map1 op map2); \ } -#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \ - { \ - boost::unordered_multimap map1, map2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ - BOOST_TEST(map1 op map2); \ +#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \ + { \ + boost::unordered_multimap \ + map1, map2; \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ + BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ + BOOST_TEST(map1 op map2); \ } #define UNORDERED_SET_INSERT(r, set, item) set.insert(item); diff --git a/test/unordered/equivalent_keys_tests.cpp b/test/unordered/equivalent_keys_tests.cpp index 10f3ac1c..994bc668 100644 --- a/test/unordered/equivalent_keys_tests.cpp +++ b/test/unordered/equivalent_keys_tests.cpp @@ -44,17 +44,20 @@ UNORDERED_AUTO_TEST(set_tests) {986, 25, 986} }; - test_equal_insertion >(values[0], values[0] + 1); - test_equal_insertion >(values[1], values[1] + 2); - test_equal_insertion >(values[2], values[2] + 2); - test_equal_insertion >(values[3], values[3] + 2); - test_equal_insertion >(values[4], values[4] + 3); + typedef boost::unordered_set set; + typedef boost::unordered_multiset multiset; - test_equal_insertion >(values[0], values[0] + 1); - test_equal_insertion >(values[1], values[1] + 2); - test_equal_insertion >(values[2], values[2] + 2); - test_equal_insertion >(values[3], values[3] + 2); - test_equal_insertion >(values[4], values[4] + 3); + test_equal_insertion(values[0], values[0] + 1); + test_equal_insertion(values[1], values[1] + 2); + test_equal_insertion(values[2], values[2] + 2); + test_equal_insertion(values[3], values[3] + 2); + test_equal_insertion(values[4], values[4] + 3); + + test_equal_insertion(values[0], values[0] + 1); + test_equal_insertion(values[1], values[1] + 2); + test_equal_insertion(values[2], values[2] + 2); + test_equal_insertion(values[3], values[3] + 2); + test_equal_insertion(values[4], values[4] + 3); } UNORDERED_AUTO_TEST(map_tests) diff --git a/test/unordered/erase_equiv_tests.cpp b/test/unordered/erase_equiv_tests.cpp index 010414be..bb2e5b1b 100644 --- a/test/unordered/erase_equiv_tests.cpp +++ b/test/unordered/erase_equiv_tests.cpp @@ -135,7 +135,8 @@ template void erase_subrange_tests(Container const& x) { for(std::size_t length = 0; length < x.size(); ++length) { - for(std::size_t position = 0; position < x.size() - length; ++position) { + for(std::size_t position = 0; position < x.size() - length; ++position) + { Container y(x); collide_list init(y.begin(), y.end()); if(!general_erase_range_test(y, position, position + length)) { diff --git a/test/unordered/erase_tests.cpp b/test/unordered/erase_tests.cpp index 1bc6e4c6..ca54bf03 100644 --- a/test/unordered/erase_tests.cpp +++ b/test/unordered/erase_tests.cpp @@ -23,14 +23,15 @@ namespace erase_tests test::seed_t seed(85638); template -void erase_tests1(Container*, test::random_generator generator = test::default_generator) +void erase_tests1(Container*, + test::random_generator generator = test::default_generator) { std::cerr<<"Erase by key.\n"; { test::random_values v(1000, generator); Container x(v.begin(), v.end()); - for(BOOST_DEDUCED_TYPENAME test::random_values::iterator it = v.begin(); - it != v.end(); ++it) + for(BOOST_DEDUCED_TYPENAME test::random_values::iterator + it = v.begin(); it != v.end(); ++it) { std::size_t count = x.count(test::get_key(*it)); std::size_t old_size = x.size(); @@ -48,9 +49,11 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g std::size_t size = x.size(); while(size > 0 && !x.empty()) { - BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*x.begin()); + BOOST_DEDUCED_TYPENAME Container::key_type + key = test::get_key(*x.begin()); std::size_t count = x.count(key); - BOOST_DEDUCED_TYPENAME Container::iterator pos = x.erase(x.begin()); + BOOST_DEDUCED_TYPENAME Container::iterator + pos = x.erase(x.begin()); --size; BOOST_TEST(pos == x.begin()); BOOST_TEST(x.count(key) == count - 1); @@ -77,7 +80,8 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g pos = boost::next(prev); } next = boost::next(pos); - BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*pos); + BOOST_DEDUCED_TYPENAME Container::key_type + key = test::get_key(*pos); std::size_t count = x.count(key); BOOST_TEST(next == x.erase(pos)); --size; @@ -119,7 +123,8 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g std::size_t size = x.size(); while(size > 0 && !x.empty()) { - BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*x.begin()); + BOOST_DEDUCED_TYPENAME Container::key_type + key = test::get_key(*x.begin()); std::size_t count = x.count(key); x.erase_return_void(x.begin()); --size; @@ -147,7 +152,8 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g pos = boost::next(prev); } next = boost::next(pos); - BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*pos); + BOOST_DEDUCED_TYPENAME Container::key_type + key = test::get_key(*pos); std::size_t count = x.count(key); x.erase_return_void(pos); --size; @@ -173,10 +179,18 @@ void erase_tests1(Container*, test::random_generator generator = test::default_g std::cerr<<"\n"; } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/find_tests.cpp b/test/unordered/find_tests.cpp index e823a04d..363de0c6 100644 --- a/test/unordered/find_tests.cpp +++ b/test/unordered/find_tests.cpp @@ -35,7 +35,8 @@ void find_tests1(X*, test::random_generator generator = test::default_generator) { BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key(*it1); iterator pos = x.find(key); - BOOST_DEDUCED_TYPENAME X::const_iterator const_pos = x_const.find(key); + BOOST_DEDUCED_TYPENAME X::const_iterator + const_pos = x_const.find(key); BOOST_TEST(pos != x.end() && x.key_eq()(key, test::get_key(*pos))); BOOST_TEST(const_pos != x_const.end() && @@ -109,10 +110,12 @@ struct compatible_predicate }; template -void find_compatible_keys_test(X*, test::random_generator generator = test::default_generator) +void find_compatible_keys_test(X*, + test::random_generator generator = test::default_generator) { typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; - typedef BOOST_DEDUCED_TYPENAME test::random_values::iterator value_iterator; + typedef BOOST_DEDUCED_TYPENAME test::random_values::iterator + value_iterator; test::random_values v(500, generator); X x(v.begin(), v.end()); @@ -132,10 +135,18 @@ void find_compatible_keys_test(X*, test::random_generator generator = test::defa } } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/fwd_set_test.cpp b/test/unordered/fwd_set_test.cpp index 866ffc4f..b868f62d 100644 --- a/test/unordered/fwd_set_test.cpp +++ b/test/unordered/fwd_set_test.cpp @@ -47,7 +47,8 @@ bool call_not_equals(int_multiset& x, int_multiset& y) { #include "../helpers/test.hpp" UNORDERED_AUTO_TEST(use_fwd_declared_trait_without_definition) { - BOOST_TEST(sizeof(is_unordered_set_impl((int_set*) 0)) == sizeof(true_type)); + BOOST_TEST(sizeof(is_unordered_set_impl((int_set*) 0)) + == sizeof(true_type)); } #include diff --git a/test/unordered/incomplete_test.cpp b/test/unordered/incomplete_test.cpp index a8bf784a..08455600 100644 --- a/test/unordered/incomplete_test.cpp +++ b/test/unordered/incomplete_test.cpp @@ -25,10 +25,14 @@ namespace test // Declare some instances - typedef boost::unordered_map > > map; - typedef boost::unordered_multimap > > multimap; - typedef boost::unordered_set > set; - typedef boost::unordered_multiset > multiset; + typedef boost::unordered_map > > map; + typedef boost::unordered_multimap > > multimap; + typedef boost::unordered_set > set; + typedef boost::unordered_multiset > multiset; // Now define the types which are stored as members, as they are needed for // declaring struct members. @@ -51,19 +55,24 @@ namespace test { // Declare some members of a structs. // - // Incomplete hash, equals and allocator aren't here supported at the moment. + // Incomplete hash, equals and allocator aren't here supported at the + // moment. struct struct1 { - boost::unordered_map > > x; + boost::unordered_map > > x; }; struct struct2 { - boost::unordered_multimap > > x; + boost::unordered_multimap > > x; }; struct struct3 { - boost::unordered_set > x; + boost::unordered_set > x; }; struct struct4 { - boost::unordered_multiset > x; + boost::unordered_multiset > x; }; // Now define the value type. @@ -81,7 +90,9 @@ namespace test test::struct2 c2; test::struct3 c3; test::struct4 c4; - // Now declare, but don't define, the operators required for comparing elements. + + // Now declare, but don't define, the operators required for comparing + // elements. std::size_t hash_value(value const&); bool operator==(value const&, value const&); diff --git a/test/unordered/insert_stable_tests.cpp b/test/unordered/insert_stable_tests.cpp index 4fd44f3f..86304da8 100644 --- a/test/unordered/insert_stable_tests.cpp +++ b/test/unordered/insert_stable_tests.cpp @@ -48,7 +48,8 @@ UNORDERED_AUTO_TEST(stable_insert_test1) { x.insert(insert_stable::member(1,2)); x.insert(insert_stable::member(1,3)); - boost::unordered_multiset::const_iterator it = x.begin(), end = x.end(); + boost::unordered_multiset::const_iterator + it = x.begin(), end = x.end(); BOOST_TEST(it != end); if(it != end) { BOOST_TEST(it->tag2_ == 1); ++it; } BOOST_TEST(it != end); @@ -60,9 +61,12 @@ UNORDERED_AUTO_TEST(stable_insert_test1) { UNORDERED_AUTO_TEST(stable_insert_test2) { boost::unordered_multimap x; - typedef boost::unordered_multimap::const_iterator iterator; + typedef + boost::unordered_multimap::const_iterator + iterator; - iterator it = x.insert(x.end(), std::make_pair(insert_stable::member(1,1), 1)); + iterator it + = x.insert(x.end(), std::make_pair(insert_stable::member(1,1), 1)); it = x.insert(it, std::make_pair(insert_stable::member(1,2), 2)); it = x.insert(it, std::make_pair(insert_stable::member(1,3), 3)); diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index 49f133f2..f0136b70 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -23,7 +23,8 @@ namespace insert_tests { test::seed_t seed(243432); template -void unique_insert_tests1(X*, test::random_generator generator = test::default_generator) +void unique_insert_tests1(X*, + test::random_generator generator = test::default_generator) { typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; typedef test::ordered ordered; @@ -43,7 +44,8 @@ void unique_insert_tests1(X*, test::random_generator generator = test::default_g float b = x.max_load_factor(); std::pair r1 = x.insert(*it); - std::pair r2 = tracker.insert(*it); + std::pair + r2 = tracker.insert(*it); BOOST_TEST(r1.second == r2.second); BOOST_TEST(*r1.first == *r2.first); @@ -58,7 +60,8 @@ void unique_insert_tests1(X*, test::random_generator generator = test::default_g } template -void equivalent_insert_tests1(X*, test::random_generator generator = test::default_generator) +void equivalent_insert_tests1(X*, + test::random_generator generator = test::default_generator) { std::cerr<<"insert(value) tests for containers with equivalent keys.\n"; @@ -73,7 +76,8 @@ void equivalent_insert_tests1(X*, test::random_generator generator = test::defau float b = x.max_load_factor(); BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(*it); - BOOST_DEDUCED_TYPENAME test::ordered::iterator r2 = tracker.insert(*it); + BOOST_DEDUCED_TYPENAME test::ordered::iterator r2 + = tracker.insert(*it); BOOST_TEST(*r1 == *r2); @@ -87,7 +91,8 @@ void equivalent_insert_tests1(X*, test::random_generator generator = test::defau } template -void insert_tests2(X*, test::random_generator generator = test::default_generator) +void insert_tests2(X*, + test::random_generator generator = test::default_generator) { typedef BOOST_DEDUCED_TYPENAME test::ordered tracker_type; typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; @@ -101,10 +106,11 @@ void insert_tests2(X*, test::random_generator generator = test::default_generato tracker_type tracker = test::create_ordered(x); test::random_values v(1000, generator); - for(BOOST_DEDUCED_TYPENAME test::random_values::iterator it = v.begin(); - it != v.end(); ++it) + for(BOOST_DEDUCED_TYPENAME test::random_values::iterator + it = v.begin(); it != v.end(); ++it) { - BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count(); + BOOST_DEDUCED_TYPENAME X::size_type + old_bucket_count = x.bucket_count(); float b = x.max_load_factor(); iterator r1 = x.insert(x.begin(), *it); @@ -127,10 +133,11 @@ void insert_tests2(X*, test::random_generator generator = test::default_generato tracker_type tracker = test::create_ordered(x); test::random_values v(100, generator); - for(BOOST_DEDUCED_TYPENAME test::random_values::iterator it = v.begin(); - it != v.end(); ++it) + for(BOOST_DEDUCED_TYPENAME test::random_values::iterator + it = v.begin(); it != v.end(); ++it) { - BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count(); + BOOST_DEDUCED_TYPENAME X::size_type + old_bucket_count = x.bucket_count(); float b = x.max_load_factor(); const_iterator r1 = x.insert(x_const.end(), *it); @@ -153,10 +160,11 @@ void insert_tests2(X*, test::random_generator generator = test::default_generato tracker_type tracker = test::create_ordered(x); test::random_values v(1000, generator); - for(BOOST_DEDUCED_TYPENAME test::random_values::iterator it = v.begin(); - it != v.end(); ++it) + for(BOOST_DEDUCED_TYPENAME test::random_values::iterator + it = v.begin(); it != v.end(); ++it) { - BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count(); + BOOST_DEDUCED_TYPENAME X::size_type + old_bucket_count = x.bucket_count(); float b = x.max_load_factor(); pos = x.insert(pos, *it); @@ -178,10 +186,11 @@ void insert_tests2(X*, test::random_generator generator = test::default_generato tracker_type tracker = test::create_ordered(x); test::random_values v(1000, generator); - for(BOOST_DEDUCED_TYPENAME test::random_values::iterator it = v.begin(); - it != v.end(); ++it) + for(BOOST_DEDUCED_TYPENAME test::random_values::iterator + it = v.begin(); it != v.end(); ++it) { - BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count(); + BOOST_DEDUCED_TYPENAME X::size_type + old_bucket_count = x.bucket_count(); float b = x.max_load_factor(); x.insert(it, boost::next(it)); @@ -225,7 +234,8 @@ void insert_tests2(X*, test::random_generator generator = test::default_generato #if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) template -void unique_emplace_tests1(X*, test::random_generator generator = test::default_generator) +void unique_emplace_tests1(X*, + test::random_generator generator = test::default_generator) { typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; typedef test::ordered ordered; @@ -245,7 +255,8 @@ void unique_emplace_tests1(X*, test::random_generator generator = test::default_ float b = x.max_load_factor(); std::pair r1 = x.emplace(*it); - std::pair r2 = tracker.insert(*it); + std::pair + r2 = tracker.insert(*it); BOOST_TEST(r1.second == r2.second); BOOST_TEST(*r1.first == *r2.first); @@ -260,7 +271,8 @@ void unique_emplace_tests1(X*, test::random_generator generator = test::default_ } template -void equivalent_emplace_tests1(X*, test::random_generator generator = test::default_generator) +void equivalent_emplace_tests1(X*, + test::random_generator generator = test::default_generator) { std::cerr<<"emplace(value) tests for containers with equivalent keys.\n"; @@ -275,7 +287,8 @@ void equivalent_emplace_tests1(X*, test::random_generator generator = test::defa float b = x.max_load_factor(); BOOST_DEDUCED_TYPENAME X::iterator r1 = x.emplace(*it); - BOOST_DEDUCED_TYPENAME test::ordered::iterator r2 = tracker.insert(*it); + BOOST_DEDUCED_TYPENAME test::ordered::iterator + r2 = tracker.insert(*it); BOOST_TEST(*r1 == *r2); @@ -317,14 +330,21 @@ 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. +// Some tests for when the range's value type doesn't match the container's +// value type. template -void map_insert_range_test1(X*, test::random_generator generator = test::default_generator) +void map_insert_range_test1(X*, + test::random_generator generator = test::default_generator) { std::cerr<<"map_insert_range_test1\n"; - typedef test::list > list; + typedef test::list< + std::pair< + BOOST_DEDUCED_TYPENAME X::key_type, + BOOST_DEDUCED_TYPENAME X::mapped_type + > + > list; test::random_values v(1000, generator); list l(v.begin(), v.end()); @@ -334,12 +354,17 @@ void map_insert_range_test1(X*, test::random_generator generator = test::default } template -void map_insert_range_test2(X*, test::random_generator generator = test::default_generator) +void map_insert_range_test2(X*, + test::random_generator generator = test::default_generator) { std::cerr<<"map_insert_range_test2\n"; - typedef test::list > list; - test::random_values > v(1000, generator); + typedef test::list< + std::pair + > list; + test::random_values< + boost::unordered_map + > v(1000, generator); list l(v.begin(), v.end()); X x; x.insert(l.begin(), l.end()); @@ -347,10 +372,18 @@ void map_insert_range_test2(X*, test::random_generator generator = test::default test::check_equivalent_keys(x); } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/load_factor_tests.cpp b/test/unordered/load_factor_tests.cpp index 10baf1f5..52cd0456 100644 --- a/test/unordered/load_factor_tests.cpp +++ b/test/unordered/load_factor_tests.cpp @@ -36,7 +36,8 @@ void set_load_factor_tests(X* = 0) } template -void insert_test(X*, float mlf, test::random_generator generator = test::default_generator) +void insert_test(X*, float mlf, + test::random_generator generator = test::default_generator) { X x; x.max_load_factor(mlf); diff --git a/test/unordered/move_tests.cpp b/test/unordered/move_tests.cpp index 47e77bb9..1e580848 100644 --- a/test/unordered/move_tests.cpp +++ b/test/unordered/move_tests.cpp @@ -46,7 +46,8 @@ namespace move_tests } template - void move_construct_tests1(T* ptr, test::random_generator const& generator = test::default_generator) + void move_construct_tests1(T* ptr, + test::random_generator const& generator = test::default_generator) { BOOST_DEDUCED_TYPENAME T::hasher hf; BOOST_DEDUCED_TYPENAME T::key_equal eq; @@ -75,7 +76,8 @@ namespace move_tests } template - void move_assign_tests1(T*, test::random_generator const& generator = test::default_generator) + void move_assign_tests1(T*, + test::random_generator const& generator = test::default_generator) { { test::random_values v(500, generator); @@ -116,7 +118,8 @@ namespace move_tests } { - // TODO: To do this correctly requires the fancy new allocator stuff. + // TODO: To do this correctly requires the fancy new allocator + // stuff. test::random_values v(500, generator); T y(create(v, count, hf, eq, al, 2.0), al2); BOOST_TEST(count != test::global_object_count); @@ -134,7 +137,8 @@ namespace move_tests #if defined(BOOST_HAS_RVALUE_REFS) BOOST_TEST(count == test::global_object_count); #else - BOOST_TEST(test::global_object_count.constructions - count.constructions <= + BOOST_TEST( + test::global_object_count.constructions - count.constructions <= (test::is_map::value ? 50 : 25)); BOOST_TEST(count.instances == test::global_object_count.instances); #endif @@ -147,10 +151,18 @@ namespace move_tests } */ } - boost::unordered_set >* test_set; - boost::unordered_multiset >* test_multiset; - boost::unordered_map >* test_map; - boost::unordered_multimap >* test_multimap; + boost::unordered_set >* test_set; + boost::unordered_multiset >* test_multiset; + boost::unordered_map >* test_map; + boost::unordered_multimap >* test_multimap; using test::default_generator; using test::generate_collisions; diff --git a/test/unordered/rehash_tests.cpp b/test/unordered/rehash_tests.cpp index 7f66edc1..9b419e8d 100644 --- a/test/unordered/rehash_tests.cpp +++ b/test/unordered/rehash_tests.cpp @@ -19,7 +19,8 @@ test::seed_t seed(2974); template bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n) { - return x.bucket_count() > x.size() / x.max_load_factor() && x.bucket_count() >= n; + return x.bucket_count() > x.size() / x.max_load_factor() && + x.bucket_count() >= n; } template @@ -35,7 +36,8 @@ void rehash_empty_test1(X* = 0) } template -void rehash_empty_test2(X* = 0, test::random_generator generator = test::default_generator) +void rehash_empty_test2(X* = 0, + test::random_generator generator = test::default_generator) { test::random_values v(1000, generator); test::ordered tracker; @@ -53,7 +55,8 @@ void rehash_empty_test2(X* = 0, test::random_generator generator = test::default } template -void rehash_empty_test3(X* = 0, test::random_generator generator = test::default_generator) +void rehash_empty_test3(X* = 0, + test::random_generator generator = test::default_generator) { test::random_values v(1000, generator); test::ordered tracker; @@ -72,7 +75,8 @@ void rehash_empty_test3(X* = 0, test::random_generator generator = test::default template -void rehash_test1(X* = 0, test::random_generator generator = test::default_generator) +void rehash_test1(X* = 0, + test::random_generator generator = test::default_generator) { test::random_values v(1000, generator); test::ordered tracker; diff --git a/test/unordered/simple_tests.cpp b/test/unordered/simple_tests.cpp index e7b9539e..ca343542 100644 --- a/test/unordered/simple_tests.cpp +++ b/test/unordered/simple_tests.cpp @@ -72,7 +72,8 @@ void simple_test(X const& a) { BOOST_TEST(a.size() == - (BOOST_DEDUCED_TYPENAME X::size_type) std::distance(a.begin(), a.end())); + static_cast( + std::distance(a.begin(), a.end()))); } { diff --git a/test/unordered/swap_tests.cpp b/test/unordered/swap_tests.cpp index 5fe8be91..3705cce4 100644 --- a/test/unordered/swap_tests.cpp +++ b/test/unordered/swap_tests.cpp @@ -62,7 +62,8 @@ void swap_tests1(X*, test::random_generator generator = test::default_generator) } template -void swap_tests2(X* ptr = 0, test::random_generator generator = test::default_generator) +void swap_tests2(X* ptr = 0, + test::random_generator generator = test::default_generator) { swap_tests1(ptr); @@ -98,7 +99,8 @@ void swap_tests2(X* ptr = 0, test::random_generator generator = test::default_ge X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2)); try { swap_test_impl(x, y); - BOOST_ERROR("Using swap method 1, swapping with unequal allocators didn't throw."); + BOOST_ERROR("Using swap method 1, " + "swapping with unequal allocators didn't throw."); } catch (std::runtime_error) {} } #else @@ -111,18 +113,28 @@ void swap_tests2(X* ptr = 0, test::random_generator generator = test::default_ge { test::random_values vx(100, generator), vy(100, generator); - X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1), allocator_type(1)); - X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2), allocator_type(2)); + X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1), + allocator_type(1)); + X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2), + allocator_type(2)); swap_test_impl(x, y); swap_test_impl(x, y); } #endif } -boost::unordered_set >* test_set; -boost::unordered_multiset >* test_multiset; -boost::unordered_map >* test_map; -boost::unordered_multimap >* test_multimap; +boost::unordered_set >* test_set; +boost::unordered_multiset >* test_multiset; +boost::unordered_map >* test_map; +boost::unordered_multimap >* test_multimap; UNORDERED_TEST(swap_tests1, ((test_set)(test_multiset)(test_map)(test_multimap)) diff --git a/test/unordered/unnecessary_copy_tests.cpp b/test/unordered/unnecessary_copy_tests.cpp index 40df82f6..b3a580df 100644 --- a/test/unordered/unnecessary_copy_tests.cpp +++ b/test/unordered/unnecessary_copy_tests.cpp @@ -67,25 +67,33 @@ namespace unnecessary_copy_tests } } -#define COPY_COUNT(n) \ - if(count_copies::copies != n) { \ - BOOST_ERROR("Wrong number of copies."); \ - std::cerr<<"Number of copies: "< b) { \ - BOOST_ERROR("Wrong number of copies."); \ - std::cerr<<"Number of copies: "< b) { \ + BOOST_ERROR("Wrong number of copies."); \ + std::cerr \ + << "Number of copies: " << count_copies::copies \ + << " expecting: [" << a << ", " << b << "]" << std::endl; \ } -#define MOVE_COUNT_RANGE(a, b) \ - if(count_copies::moves < a || count_copies::moves > b) { \ - BOOST_ERROR("Wrong number of moves."); \ - std::cerr<<"Number of moves: "< b) { \ + BOOST_ERROR("Wrong number of moves."); \ + std::cerr \ + << "Number of moves: " << count_copies::copies \ + << " expecting: [" << a << ", " << b << "]" << std::endl; \ } namespace unnecessary_copy_tests