From fe85038ebe876b3f65fad1eae3e19e0d56e33922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 25 Sep 2018 09:08:24 +0200 Subject: [PATCH] Simplify redundant tested variants in functional tests. Move explicit instantiations from functional tests to "explicit_inst_xxx". --- test/explicit_inst_string_test.cpp | 28 ++++- test/explicit_inst_vector_test.cpp | 25 +++- test/flat_map_test.cpp | 192 ++++++++--------------------- test/flat_set_test.cpp | 177 ++++++++------------------ test/global_resource_test.cpp | 16 ++- test/list_test.cpp | 19 +-- test/map_test.cpp | 157 +++++++++-------------- test/movable_int.hpp | 12 ++ test/set_test.cpp | 162 +++++++++--------------- test/slist_test.cpp | 54 ++------ test/small_vector_test.cpp | 26 ---- test/stable_vector_test.cpp | 16 --- test/static_vector_test.cpp | 8 -- test/string_test.cpp | 22 ---- test/vector_test.cpp | 17 --- 15 files changed, 312 insertions(+), 619 deletions(-) diff --git a/test/explicit_inst_string_test.cpp b/test/explicit_inst_string_test.cpp index f911bb0..fd76969 100644 --- a/test/explicit_inst_string_test.cpp +++ b/test/explicit_inst_string_test.cpp @@ -11,10 +11,34 @@ #include template class ::boost::container::basic_string; +volatile ::boost::container::basic_string dummy; + +#include +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +typedef test::simple_allocator SimpleCharAllocator; +typedef basic_string, SimpleCharAllocator> SimpleString; +typedef test::simple_allocator SimpleStringAllocator; +typedef test::simple_allocator SimpleWCharAllocator; +typedef basic_string, SimpleWCharAllocator> SimpleWString; +typedef test::simple_allocator SimpleWStringAllocator; + +//Explicit instantiations of container::basic_string +template class basic_string, SimpleCharAllocator>; +template class basic_string, SimpleWCharAllocator>; +template class basic_string, std::allocator >; +template class basic_string, std::allocator >; + +//Explicit instantiation of container::vectors of container::strings +template class vector; +template class vector; + +}} int main() { - ::boost::container::basic_string dummy; - (void)dummy; return 0; } diff --git a/test/explicit_inst_vector_test.cpp b/test/explicit_inst_vector_test.cpp index b03427c..619dfc9 100644 --- a/test/explicit_inst_vector_test.cpp +++ b/test/explicit_inst_vector_test.cpp @@ -17,10 +17,31 @@ struct empty }; template class ::boost::container::vector; +volatile ::boost::container::vector dummy; + +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors +template class boost::container::vector + < test::movable_and_copyable_int + , test::simple_allocator >; + +template class boost::container::vector + < test::movable_and_copyable_int + , allocator >; + +template class vec_iterator; +template class vec_iterator; + +} //namespace boost { +} //namespace container { int main() { - ::boost::container::vector dummy; - (void)dummy; return 0; } diff --git a/test/flat_map_test.cpp b/test/flat_map_test.cpp index 8118591..bd7af01 100644 --- a/test/flat_map_test.cpp +++ b/test/flat_map_test.cpp @@ -7,15 +7,9 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #include #include #include -#include -#include -#include -#include -#include #include #include "print_container.hpp" @@ -32,72 +26,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors - -//flat_map -typedef std::pair test_pair_t; - -template class flat_map - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , test::simple_allocator< test_pair_t > - >; - -template class flat_map - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , small_vector< test_pair_t, 10, std::allocator< test_pair_t > > - >; - -//flat_multimap -template class flat_multimap - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , stable_vector< test_pair_t, allocator< test_pair_t > > - >; - -template class flat_multimap - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , deque > - >; - -template class flat_multimap - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , static_vector - >; - -//As flat container iterators are typedefs for vector::[const_]iterator, -//no need to explicit instantiate them - -}} //boost::container - -#if (__cplusplus > 201103L) -#include - -namespace boost{ -namespace container{ - -template class flat_map - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , std::vector ->; - -}} //boost::container - -#endif - class recursive_flat_map { public: @@ -545,65 +473,10 @@ bool test_heterogeneous_lookups() }}} //namespace boost::container::test -template -int test_map_variants() -{ - typedef typename GetMapContainer::template apply::map_type MyMap; - typedef typename GetMapContainer::template apply::map_type MyMoveMap; - typedef typename GetMapContainer::template apply::map_type MyCopyMoveMap; - typedef typename GetMapContainer::template apply::map_type MyCopyMap; - - typedef typename GetMapContainer::template apply::multimap_type MyMultiMap; - typedef typename GetMapContainer::template apply::multimap_type MyMoveMultiMap; - typedef typename GetMapContainer::template apply::multimap_type MyCopyMoveMultiMap; - typedef typename GetMapContainer::template apply::multimap_type MyCopyMultiMap; - - typedef std::map MyStdMap; - typedef std::multimap MyStdMultiMap; - - if (0 != test::map_test< - MyMap - ,MyStdMap - ,MyMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != test::map_test< - MyMoveMap - ,MyStdMap - ,MyMoveMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != test::map_test< - MyCopyMoveMap - ,MyStdMap - ,MyCopyMoveMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != test::map_test< - MyCopyMap - ,MyStdMap - ,MyCopyMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - return 0; -} - int main() { using namespace boost::container::test; - +/* //Allocator argument container { flat_map map_((flat_map::allocator_type())); @@ -657,21 +530,60 @@ int main() if (!test_heterogeneous_lookups()) return 1; - +*/ //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std::allocator - if(test_map_variants< std::allocator >()){ - std::cerr << "test_map_variants< std::allocator > failed" << std::endl; - return 1; - } - // boost::container::allocator - if(test_map_variants< allocator >()){ - std::cerr << "test_map_variants< allocator > failed" << std::endl; - return 1; - } + { + typedef std::map MyStdMap; + typedef std::multimap MyStdMultiMap; + if (0 != test::map_test + < GetMapContainer >::apply::map_type + , MyStdMap + , GetMapContainer >::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test >" << std::endl; + return 1; + } + /* + if (0 != test::map_test + < GetMapContainer >::apply::map_type + , MyStdMap + , GetMapContainer >::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test >" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetMapContainer >::apply::map_type + , MyStdMap + , GetMapContainer >::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test >" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetMapContainer >::apply::map_type + , MyStdMap + , GetMapContainer >::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test >" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetMapContainer >::apply::map_type + , MyStdMap + , GetMapContainer >::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test >" << std::endl; + return 1; + }*/ + } +/* if(!boost::container::test::test_map_support_for_initialization_list_for >()) return 1; @@ -716,7 +628,7 @@ int main() return 1; } } - +*/ return 0; } diff --git a/test/flat_set_test.cpp b/test/flat_set_test.cpp index e720932..753c074 100644 --- a/test/flat_set_test.cpp +++ b/test/flat_set_test.cpp @@ -13,11 +13,6 @@ #include #include -#include -#include -#include -#include -#include #include #include "print_container.hpp" @@ -31,65 +26,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors - -//flat_set -template class flat_set - < test::movable_and_copyable_int - , std::less - , test::simple_allocator - >; - -template class flat_set - < test::movable_and_copyable_int - , std::less - , small_vector > - >; - -//flat_multiset -template class flat_multiset - < test::movable_and_copyable_int - , std::less - , stable_vector > - >; - -template class flat_multiset - < test::movable_and_copyable_int - , std::less - , deque > - >; - -template class flat_multiset - < test::movable_and_copyable_int - , std::less - , static_vector - >; - -//As flat container iterators are typedefs for vector::[const_]iterator, -//no need to explicit instantiate them - -}} //boost::container - - -#if (__cplusplus > 201103L) -#include - -namespace boost{ -namespace container{ - -template class flat_set - < test::movable_and_copyable_int - , std::less - , std::vector ->; - -}} //boost::container - -#endif - //Test recursive structures class recursive_flat_set { @@ -558,62 +494,6 @@ struct GetSetContainer }; }; -template -int test_set_variants() -{ - typedef typename GetSetContainer::template apply::set_type MySet; - typedef typename GetSetContainer::template apply::set_type MyMoveSet; - typedef typename GetSetContainer::template apply::set_type MyCopyMoveSet; - typedef typename GetSetContainer::template apply::set_type MyCopySet; - - typedef typename GetSetContainer::template apply::multiset_type MyMultiSet; - typedef typename GetSetContainer::template apply::multiset_type MyMoveMultiSet; - typedef typename GetSetContainer::template apply::multiset_type MyCopyMoveMultiSet; - typedef typename GetSetContainer::template apply::multiset_type MyCopyMultiSet; - - typedef std::set MyStdSet; - typedef std::multiset MyStdMultiSet; - - if (0 != test::set_test< - MySet - ,MyStdSet - ,MyMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - if (0 != test::set_test< - MyMoveSet - ,MyStdSet - ,MyMoveMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - if (0 != test::set_test< - MyCopyMoveSet - ,MyStdSet - ,MyCopyMoveMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - if (0 != test::set_test< - MyCopySet - ,MyStdSet - ,MyCopyMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - return 0; -} - - template bool test_support_for_initialization_list_for() { @@ -731,15 +611,54 @@ int main() //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std::allocator - if(test_set_variants< std::allocator >()){ - std::cerr << "test_set_variants< std::allocator > failed" << std::endl; - return 1; - } - // boost::container::allocator - if(test_set_variants< allocator >()){ - std::cerr << "test_set_variants< allocator > failed" << std::endl; - return 1; + { + typedef std::set MyStdSet; + typedef std::multiset MyStdMultiSet; + + if (0 != test::set_test + < GetSetContainer >::apply::set_type + , MyStdSet + , GetSetContainer >::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test >" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetSetContainer >::apply::set_type + , MyStdSet + , GetSetContainer >::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test >" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetSetContainer >::apply::set_type + , MyStdSet + , GetSetContainer >::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test >" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetSetContainer >::apply::set_type + , MyStdSet + , GetSetContainer >::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test >" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetSetContainer >::apply::set_type + , MyStdSet + , GetSetContainer >::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test >" << std::endl; + return 1; + } } //////////////////////////////////// diff --git a/test/global_resource_test.cpp b/test/global_resource_test.cpp index c04816a..7f689cb 100644 --- a/test/global_resource_test.cpp +++ b/test/global_resource_test.cpp @@ -20,8 +20,6 @@ using namespace boost::container; using namespace boost::container::pmr; -std::size_t allocation_count = 0; - #ifdef BOOST_MSVC #pragma warning (push) #pragma warning (disable : 4290) @@ -39,6 +37,11 @@ std::size_t allocation_count = 0; #pragma GCC diagnostic ignored "-Wsized-deallocation" #endif +//ASAN does not support operator new overloading +#ifndef BOOST_CONTAINER_ASAN + +std::size_t allocation_count = 0; + void* operator new[](std::size_t count) BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER { ++allocation_count; @@ -51,10 +54,15 @@ void operator delete[](void *p) BOOST_CONTAINER_DELETE_EXCEPTION_SPECIFIER return std::free(p); } +#endif //BOOST_CONTAINER_ASAN + #ifdef BOOST_MSVC #pragma warning (pop) #endif +#define BOOST_CONTAINER_ASAN +#ifndef BOOST_CONTAINER_ASAN + void test_new_delete_resource() { //Make sure new_delete_resource calls new[]/delete[] @@ -73,6 +81,8 @@ void test_new_delete_resource() BOOST_TEST(memcount == allocation_count); } +#endif //BOOST_CONTAINER_ASAN + void test_null_memory_resource() { //Make sure it throw or returns null @@ -109,7 +119,9 @@ void test_default_resource() int main() { + #ifndef BOOST_CONTAINER_ASAN test_new_delete_resource(); + #endif test_null_memory_resource(); test_default_resource(); return ::boost::report_errors(); diff --git a/test/list_test.cpp b/test/list_test.cpp index aefa008..8348725 100644 --- a/test/list_test.cpp +++ b/test/list_test.cpp @@ -168,16 +168,19 @@ int main () //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std:allocator - if(test_cont_variants< std::allocator >()){ - std::cerr << "test_cont_variants< std::allocator > failed" << std::endl; + // int variants + if (test::list_test >, true>()) return 1; - } - // boost::container::adaptive_pool - if(test_cont_variants< adaptive_pool >()){ - std::cerr << "test_cont_variants< adaptive_pool > failed" << std::endl; + if (test::list_test, true>()) + return 1; + if (test::list_test >, true>()) + return 1; + if (test::list_test, true>()) + return 1; + if (test::list_test, true>()) + return 1; + if (test::list_test, true>()) return 1; - } //////////////////////////////////// // Emplace testing diff --git a/test/map_test.cpp b/test/map_test.cpp index ec4c33e..ca323f2 100644 --- a/test/map_test.cpp +++ b/test/map_test.cpp @@ -25,34 +25,6 @@ using namespace boost::container; typedef std::pair pair_t; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors - -//map -template class map - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , test::simple_allocator< pair_t > - >; - -template class map - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , adaptive_pool< pair_t > - >; - -template class multimap - < test::movable_and_copyable_int - , test::movable_and_copyable_int - , std::less - , std::allocator< pair_t > - >; -}} //boost::container - class recursive_map { public: @@ -240,50 +212,6 @@ struct GetAllocatorMap }; }; -template -int test_map_variants() -{ - typedef typename GetAllocatorMap::template apply::map_type MyMap; - typedef typename GetAllocatorMap::template apply::map_type MyMoveMap; - typedef typename GetAllocatorMap::template apply::map_type MyCopyMap; - - typedef typename GetAllocatorMap::template apply::multimap_type MyMultiMap; - typedef typename GetAllocatorMap::template apply::multimap_type MyMoveMultiMap; - typedef typename GetAllocatorMap::template apply::multimap_type MyCopyMultiMap; - - typedef std::map MyStdMap; - typedef std::multimap MyStdMultiMap; - - if (0 != test::map_test< - MyMap - ,MyStdMap - ,MyMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != test::map_test< - MyMoveMap - ,MyStdMap - ,MyMoveMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != test::map_test< - MyCopyMap - ,MyStdMap - ,MyCopyMultiMap - ,MyStdMultiMap>()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - return 0; -} - struct boost_container_map; struct boost_container_multimap; @@ -441,34 +369,65 @@ int main () //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std:allocator - if(test_map_variants< std::allocator, red_black_tree >()){ - std::cerr << "test_map_variants< std::allocator > failed" << std::endl; - return 1; - } - // boost::container::adaptive_pool - if(test_map_variants< adaptive_pool, red_black_tree >()){ - std::cerr << "test_map_variants< adaptive_pool > failed" << std::endl; - return 1; - } + { + typedef std::map MyStdMap; + typedef std::multimap MyStdMultiMap; - //////////////////////////////////// - // Tree implementations - //////////////////////////////////// - // AVL - if(test_map_variants< std::allocator, avl_tree >()){ - std::cerr << "test_map_variants< std::allocator, avl_tree > failed" << std::endl; - return 1; - } - // SCAPEGOAT TREE - if(test_map_variants< std::allocator, scapegoat_tree >()){ - std::cerr << "test_map_variants< std::allocator, scapegoat_tree > failed" << std::endl; - return 1; - } - // SPLAY TREE - if(test_map_variants< std::allocator, splay_tree >()){ - std::cerr << "test_map_variants< std::allocator, splay_tree > failed" << std::endl; - return 1; + if (0 != test::map_test + < GetAllocatorMap, red_black_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, red_black_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, red_black_tree>" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetAllocatorMap, avl_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, avl_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, avl_tree>" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetAllocatorMap, scapegoat_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, scapegoat_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, scapegoat_tree>" << std::endl; + return 1; + } + + /////////// + + if (0 != test::map_test + < GetAllocatorMap, splay_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, splay_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, splay_tree>" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetAllocatorMap, red_black_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, red_black_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, red_black_tree>" << std::endl; + return 1; + } + + if (0 != test::map_test + < GetAllocatorMap, red_black_tree>::apply::map_type + , MyStdMap + , GetAllocatorMap, red_black_tree>::apply::multimap_type + , MyStdMultiMap>()) { + std::cout << "Error in map_test, red_black_tree>" << std::endl; + return 1; + } } //////////////////////////////////// diff --git a/test/movable_int.hpp b/test/movable_int.hpp index c8513c0..c38146e 100644 --- a/test/movable_int.hpp +++ b/test/movable_int.hpp @@ -103,6 +103,9 @@ class movable_int friend bool operator<(int l, const movable_int &r) { return l < r.get_int(); } + friend std::size_t hash_value(const movable_int &v) + { return (std::size_t)v.get_int(); } + private: int m_int; }; @@ -205,6 +208,9 @@ class movable_and_copyable_int friend bool operator<(int l, const movable_and_copyable_int &r) { return l < r.get_int(); } + friend std::size_t hash_value(const movable_and_copyable_int &v) + { return (std::size_t)v.get_int(); } + private: int m_int; }; @@ -298,6 +304,9 @@ class copyable_int friend bool operator<(int l, const copyable_int &r) { return l < r.get_int(); } + friend std::size_t hash_value(const copyable_int &v) + { return (std::size_t)v.get_int(); } + private: int m_int; }; @@ -375,6 +384,9 @@ class non_copymovable_int friend bool operator<(int l, const non_copymovable_int &r) { return l < r.get_int(); } + friend std::size_t hash_value(const non_copymovable_int &v) + { return (std::size_t)v.get_int(); } + private: int m_int; }; diff --git a/test/set_test.cpp b/test/set_test.cpp index 7a693fc..33cc0a4 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -22,39 +22,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors - -//set -template class set - < test::movable_and_copyable_int - , std::less - , test::simple_allocator - >; - -template class set - < test::movable_and_copyable_int - , std::less - , new_allocator - >; - -//multiset -template class multiset - < test::movable_and_copyable_int - , std::less - , test::simple_allocator - >; - -template class multiset - < test::movable_and_copyable_int - , std::less - , adaptive_pool - >; - -}} //boost::container - //Test recursive structures class recursive_set { @@ -267,50 +234,6 @@ struct GetAllocatorSet }; }; -template -int test_set_variants() -{ - typedef typename GetAllocatorSet::template apply::set_type MySet; - typedef typename GetAllocatorSet::template apply::set_type MyMoveSet; - typedef typename GetAllocatorSet::template apply::set_type MyCopySet; - - typedef typename GetAllocatorSet::template apply::multiset_type MyMultiSet; - typedef typename GetAllocatorSet::template apply::multiset_type MyMoveMultiSet; - typedef typename GetAllocatorSet::template apply::multiset_type MyCopyMultiSet; - - typedef std::set MyStdSet; - typedef std::multiset MyStdMultiSet; - - if (0 != test::set_test< - MySet - ,MyStdSet - ,MyMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - if (0 != test::set_test< - MyMoveSet - ,MyStdSet - ,MyMoveMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - if (0 != test::set_test< - MyCopySet - ,MyStdSet - ,MyCopyMultiSet - ,MyStdMultiSet>()){ - std::cout << "Error in set_test" << std::endl; - return 1; - } - - return 0; -} - void test_merge_from_different_comparison() { set set1; @@ -443,34 +366,65 @@ int main () //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std:allocator - if(test_set_variants< std::allocator, red_black_tree >()){ - std::cerr << "test_set_variants< std::allocator > failed" << std::endl; - return 1; - } - // boost::container::adaptive_pool - if(test_set_variants< adaptive_pool, red_black_tree>()){ - std::cerr << "test_set_variants< adaptive_pool > failed" << std::endl; - return 1; - } + { + typedef std::set MyStdSet; + typedef std::multiset MyStdMultiSet; - //////////////////////////////////// - // Tree implementations - //////////////////////////////////// - // AVL - if(test_set_variants< std::allocator, avl_tree >()){ - std::cerr << "test_set_variants< std::allocator, avl_tree > failed" << std::endl; - return 1; - } - // SCAPEGOAT TREE - if(test_set_variants< std::allocator, scapegoat_tree >()){ - std::cerr << "test_set_variants< std::allocator, scapegoat_tree > failed" << std::endl; - return 1; - } - // SPLAY TREE - if(test_set_variants< std::allocator, splay_tree >()){ - std::cerr << "test_set_variants< std::allocator, splay_tree > failed" << std::endl; - return 1; + if (0 != test::set_test + < GetAllocatorSet, red_black_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, red_black_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, red_black_tree>" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetAllocatorSet, avl_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, avl_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, avl_tree>" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetAllocatorSet, scapegoat_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, scapegoat_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, scapegoat_tree>" << std::endl; + return 1; + } + + /////////// + + if (0 != test::set_test + < GetAllocatorSet, splay_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, splay_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, splay_tree>" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetAllocatorSet, red_black_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, red_black_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, red_black_tree>" << std::endl; + return 1; + } + + if (0 != test::set_test + < GetAllocatorSet, red_black_tree>::apply::set_type + , MyStdSet + , GetAllocatorSet, red_black_tree>::apply::multiset_type + , MyStdMultiSet>()) { + std::cout << "Error in set_test, red_black_tree>" << std::endl; + return 1; + } } //////////////////////////////////// diff --git a/test/slist_test.cpp b/test/slist_test.cpp index 3f1f910..543eba1 100644 --- a/test/slist_test.cpp +++ b/test/slist_test.cpp @@ -21,20 +21,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors -template class boost::container::slist - < test::movable_and_copyable_int - , test::simple_allocator >; - -template class boost::container::slist - < test::movable_and_copyable_int - , node_allocator >; - -}} - class recursive_slist { public: @@ -65,28 +51,6 @@ struct GetAllocatorCont }; }; -template -int test_cont_variants() -{ - typedef typename GetAllocatorCont::template apply::type MyCont; - typedef typename GetAllocatorCont::template apply::type MyMoveCont; - typedef typename GetAllocatorCont::template apply::type MyCopyMoveCont; - typedef typename GetAllocatorCont::template apply::type MyCopyCont; - - if(test::list_test()) - return 1; - if(test::list_test()) - return 1; - if(test::list_test()) - return 1; - if(test::list_test()) - return 1; - if(test::list_test()) - return 1; - - return 0; -} - bool test_support_for_initializer_list() { #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -201,16 +165,18 @@ int main () //////////////////////////////////// // Testing allocator implementations //////////////////////////////////// - // std:allocator - if(test_cont_variants< std::allocator >()){ - std::cerr << "test_cont_variants< std::allocator > failed" << std::endl; + if (test::list_test >, false>()) return 1; - } - // boost::container::node_allocator - if(test_cont_variants< node_allocator >()){ - std::cerr << "test_cont_variants< node_allocator > failed" << std::endl; + if (test::list_test, false>()) + return 1; + if (test::list_test >, false>()) + return 1; + if (test::list_test, false>()) + return 1; + if (test::list_test, false>()) + return 1; + if (test::list_test, false>()) return 1; - } //////////////////////////////////// // Emplace testing diff --git a/test/small_vector_test.cpp b/test/small_vector_test.cpp index adf5f65..e3b7600 100644 --- a/test/small_vector_test.cpp +++ b/test/small_vector_test.cpp @@ -18,32 +18,6 @@ #include -namespace boost { -namespace container { - -template class small_vector; -template class small_vector; -template class small_vector; -template class small_vector; - -template class small_vector; -template class small_vector; -template class small_vector; -template class small_vector; - -//Explicit instantiation to detect compilation errors -template class boost::container::small_vector - < test::movable_and_copyable_int - , 10 - , test::simple_allocator >; - -template class boost::container::small_vector - < test::movable_and_copyable_int - , 10 - , allocator >; - -}} - struct boost_container_small_vector; namespace boost { namespace container { namespace test { diff --git a/test/stable_vector_test.cpp b/test/stable_vector_test.cpp index 16e2ca8..7fb1014 100644 --- a/test/stable_vector_test.cpp +++ b/test/stable_vector_test.cpp @@ -26,22 +26,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors -template class stable_vector >; - -template class stable_vector - < test::movable_and_copyable_int - , node_allocator >; - -template class stable_vector_iterator; -template class stable_vector_iterator; - -}} - class recursive_vector { public: diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index d8c6ff3..f47df2e 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -20,14 +20,6 @@ #include "static_vector_test.hpp" -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors -template class boost::container::static_vector; - -}} - template void test_ctor_ndc() diff --git a/test/string_test.cpp b/test/string_test.cpp index 16397b0..4c15fe6 100644 --- a/test/string_test.cpp +++ b/test/string_test.cpp @@ -31,28 +31,6 @@ using namespace boost::container; -typedef test::simple_allocator SimpleCharAllocator; -typedef basic_string, SimpleCharAllocator> SimpleString; -typedef test::simple_allocator SimpleStringAllocator; -typedef test::simple_allocator SimpleWCharAllocator; -typedef basic_string, SimpleWCharAllocator> SimpleWString; -typedef test::simple_allocator SimpleWStringAllocator; - -namespace boost { -namespace container { - -//Explicit instantiations of container::basic_string -template class basic_string, SimpleCharAllocator>; -template class basic_string, SimpleWCharAllocator>; -template class basic_string, std::allocator >; -template class basic_string, std::allocator >; - -//Explicit instantiation of container::vectors of container::strings -template class vector; -template class vector; - -}} - struct StringEqual { template diff --git a/test/vector_test.cpp b/test/vector_test.cpp index 201f201..1e74451 100644 --- a/test/vector_test.cpp +++ b/test/vector_test.cpp @@ -33,23 +33,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors -template class boost::container::vector - < test::movable_and_copyable_int - , test::simple_allocator >; - -template class boost::container::vector - < test::movable_and_copyable_int - , allocator >; - -template class vec_iterator; -template class vec_iterator; - -}} - int test_expand_bwd() { //Now test all back insertion possibilities