From d01cb72b3f375f58488173b6d840035da20ab54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 14 Apr 2015 15:03:19 +0200 Subject: [PATCH] Add iterator tests --- test/deque_test.cpp | 14 ++++++++++++- test/flat_map_test.cpp | 21 ++++++++++++++++++++ test/flat_set_test.cpp | 39 +++++++++++++++++++++++++++++++++++++ test/list_test.cpp | 26 +++++++++++++++---------- test/map_test.cpp | 21 ++++++++++++++++++++ test/set_test.cpp | 21 ++++++++++++++++++++ test/slist_test.cpp | 16 +++++++++++++++ test/small_vector_test.cpp | 13 +++++++++++++ test/stable_vector_test.cpp | 13 +++++++++++++ test/static_vector_test.cpp | 10 ++++++++++ test/string_test.cpp | 21 ++++++++++++++++++++ test/vector_test.cpp | 14 ++++++++++++- 12 files changed, 217 insertions(+), 12 deletions(-) diff --git a/test/deque_test.cpp b/test/deque_test.cpp index 3a32e6b..f54fec3 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -33,6 +33,7 @@ #include "vector_test.hpp" #include "default_init_test.hpp" #include +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -426,7 +427,18 @@ int main () < boost::container::deque >()) { return 1; } - return 0; + + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::deque cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } return 0; } diff --git a/test/flat_map_test.cpp b/test/flat_map_test.cpp index 8a8ec08..00d8b6f 100644 --- a/test/flat_map_test.cpp +++ b/test/flat_map_test.cpp @@ -22,6 +22,7 @@ #include "propagate_allocator_test.hpp" #include "container_common_tests.hpp" #include "emplace_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" #include #include @@ -498,6 +499,26 @@ int main() if(!boost::container::test::test_propagate_allocator()) return 1; + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::flat_map cont_int; + cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9)); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + { + typedef boost::container::flat_multimap cont_int; + cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9)); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } diff --git a/test/flat_set_test.cpp b/test/flat_set_test.cpp index 26b5a63..02f2fbc 100644 --- a/test/flat_set_test.cpp +++ b/test/flat_set_test.cpp @@ -24,6 +24,7 @@ #include "container_common_tests.hpp" #include #include +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -272,6 +273,24 @@ bool flat_tree_ordered_insertion_test() int_mset4.insert(int_even_mset.begin(), int_even_mset.end()); if(!CheckEqualContainers(int_mset4, fmset)) return false; + + //Re-re-insertion using in-place merge + fmset.reserve(fmset.size() + int_mset2.size()); + fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end()); + std::multiset int_mset5(int_mset2); + int_mset4.insert(int_mset5.begin(), int_mset5.end()); + if(!CheckEqualContainers(int_mset4, fmset)) + return false; + //Re-re-insertion of even + std::multiset int_even_mset2; + for(std::size_t i = 0; i < NumElements; i+=2){ + int_even_mset2.insert(static_cast(i)); + } + fmset.reserve(fmset.size() + int_even_mset2.size()); + fmset.insert(ordered_range, int_even_mset2.begin(), int_even_mset2.end()); + int_mset4.insert(int_even_mset2.begin(), int_even_mset2.end()); + if(!CheckEqualContainers(int_mset4, fmset)) + return false; } //Ordered insertion set @@ -605,6 +624,26 @@ int main() if(!boost::container::test::test_propagate_allocator()) return 1; + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::flat_set cont_int; + cont_int a; a.insert(0); a.insert(1); a.insert(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + { + typedef boost::container::flat_multiset cont_int; + cont_int a; a.insert(0); a.insert(1); a.insert(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } diff --git a/test/list_test.cpp b/test/list_test.cpp index 84588b7..b79a41d 100644 --- a/test/list_test.cpp +++ b/test/list_test.cpp @@ -20,6 +20,7 @@ #include "list_test.hpp" #include "propagate_allocator_test.hpp" #include "emplace_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -220,20 +221,25 @@ int main () if(!boost::container::test::test_propagate_allocator()) return 1; + //////////////////////////////////// + // Initializer lists + //////////////////////////////////// if(!test_support_for_initializer_list()) return 1; + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::list cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_bidirectional< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } #include - -/* -#include -//#include - -int main() -{ - return 0; -} -*/ diff --git a/test/map_test.cpp b/test/map_test.cpp index ebd1eab..3eb4deb 100644 --- a/test/map_test.cpp +++ b/test/map_test.cpp @@ -21,6 +21,7 @@ #include "map_test.hpp" #include "propagate_allocator_test.hpp" #include "emplace_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -434,6 +435,26 @@ int main () if (!boost::container::test::test_map_support_for_initialization_list_for >()) return 1; + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::map cont_int; + cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9)); + boost::intrusive::test::test_iterator_bidirectional< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + { + typedef boost::container::multimap cont_int; + cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9)); + boost::intrusive::test::test_iterator_bidirectional< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + //////////////////////////////////// // Test optimize_size option //////////////////////////////////// diff --git a/test/set_test.cpp b/test/set_test.cpp index b305868..6a60f98 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -20,6 +20,7 @@ #include "set_test.hpp" #include "propagate_allocator_test.hpp" #include "emplace_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -439,6 +440,26 @@ int main () typedef multiset< int*, std::less, std::allocator , tree_assoc_options< optimize_size, tree_type >::type > avlmset_size_optimized_yes; BOOST_STATIC_ASSERT(sizeof(avlmset_size_optimized_yes) < sizeof(avlmset_size_optimized_no)); + + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::set cont_int; + cont_int a; a.insert(0); a.insert(1); a.insert(2); + boost::intrusive::test::test_iterator_bidirectional< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + { + typedef boost::container::multiset cont_int; + cont_int a; a.insert(0); a.insert(1); a.insert(2); + boost::intrusive::test::test_iterator_bidirectional< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } return 0; } diff --git a/test/slist_test.cpp b/test/slist_test.cpp index f73056b..fb2a8f5 100644 --- a/test/slist_test.cpp +++ b/test/slist_test.cpp @@ -19,6 +19,7 @@ #include "list_test.hpp" #include "propagate_allocator_test.hpp" #include "emplace_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -228,8 +229,23 @@ int main () if(!boost::container::test::test_propagate_allocator()) return 1; + //////////////////////////////////// + // Initializer lists + //////////////////////////////////// if(!test_support_for_initializer_list()) return 1; + + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::slist vector_int; + vector_int a; a.push_front(2); a.push_front(1); a.push_front(0); + boost::intrusive::test::test_iterator_forward< boost::container::slist >(a); + if(boost::report_errors() != 0) { + return 1; + } + } } #include diff --git a/test/small_vector_test.cpp b/test/small_vector_test.cpp index 10a939e..5dacb7d 100644 --- a/test/small_vector_test.cpp +++ b/test/small_vector_test.cpp @@ -12,6 +12,7 @@ #include "movable_int.hpp" #include "propagate_allocator_test.hpp" #include "default_init_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" #include #include @@ -179,5 +180,17 @@ int main() return 1; } + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::small_vector cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } diff --git a/test/stable_vector_test.cpp b/test/stable_vector_test.cpp index 3ff73e3..c76675c 100644 --- a/test/stable_vector_test.cpp +++ b/test/stable_vector_test.cpp @@ -24,6 +24,7 @@ #include "propagate_allocator_test.hpp" #include "vector_test.hpp" #include "default_init_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -206,6 +207,18 @@ int main() return 1; } + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::stable_vector cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index eb48f62..dd9d75f 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "../../intrusive/test/iterator_test.hpp" #include #include @@ -811,6 +812,15 @@ int main(int, char* []) test_support_for_initializer_list(); + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::static_vector cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + } + return boost::report_errors(); } diff --git a/test/string_test.cpp b/test/string_test.cpp index 2e3f670..601e815 100644 --- a/test/string_test.cpp +++ b/test/string_test.cpp @@ -24,6 +24,7 @@ #include "expand_bwd_test_template.hpp" #include "propagate_allocator_test.hpp" #include "default_init_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -483,6 +484,26 @@ int main() return 1; } + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::basic_string cont_int; + cont_int a; a.push_back(char(1)); a.push_back(char(2)); a.push_back(char(3)); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + { + typedef boost::container::basic_string cont_int; + cont_int a; a.push_back(wchar_t(1)); a.push_back(wchar_t(2)); a.push_back(wchar_t(3)); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; } diff --git a/test/vector_test.cpp b/test/vector_test.cpp index b840262..332941a 100644 --- a/test/vector_test.cpp +++ b/test/vector_test.cpp @@ -24,6 +24,7 @@ #include "propagate_allocator_test.hpp" #include "vector_test.hpp" #include "default_init_test.hpp" +#include "../../intrusive/test/iterator_test.hpp" using namespace boost::container; @@ -263,6 +264,17 @@ int main() >()) { return 1; } - return 0; + //////////////////////////////////// + // Iterator testing + //////////////////////////////////// + { + typedef boost::container::vector cont_int; + cont_int a; a.push_back(0); a.push_back(1); a.push_back(2); + boost::intrusive::test::test_iterator_random< cont_int >(a); + if(boost::report_errors() != 0) { + return 1; + } + } + return 0; }