Simplify redundant tested variants in functional tests.

Move explicit instantiations from functional tests to "explicit_inst_xxx".
This commit is contained in:
Ion Gaztañaga
2018-09-25 09:08:24 +02:00
parent 59f70078f0
commit fe85038ebe
15 changed files with 312 additions and 619 deletions

View File

@ -11,10 +11,34 @@
#include <boost/container/string.hpp>
template class ::boost::container::basic_string<char>;
volatile ::boost::container::basic_string<char> dummy;
#include <boost/container/vector.hpp>
#include "dummy_test_allocator.hpp"
namespace boost {
namespace container {
typedef test::simple_allocator<char> SimpleCharAllocator;
typedef basic_string<char, std::char_traits<char>, SimpleCharAllocator> SimpleString;
typedef test::simple_allocator<SimpleString> SimpleStringAllocator;
typedef test::simple_allocator<wchar_t> SimpleWCharAllocator;
typedef basic_string<wchar_t, std::char_traits<wchar_t>, SimpleWCharAllocator> SimpleWString;
typedef test::simple_allocator<SimpleWString> SimpleWStringAllocator;
//Explicit instantiations of container::basic_string
template class basic_string<char, std::char_traits<char>, SimpleCharAllocator>;
template class basic_string<wchar_t, std::char_traits<wchar_t>, SimpleWCharAllocator>;
template class basic_string<char, std::char_traits<char>, std::allocator<char> >;
template class basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >;
//Explicit instantiation of container::vectors of container::strings
template class vector<SimpleString, SimpleStringAllocator>;
template class vector<SimpleWString, SimpleWStringAllocator>;
}}
int main()
{
::boost::container::basic_string<char> dummy;
(void)dummy;
return 0;
}

View File

@ -17,10 +17,31 @@ struct empty
};
template class ::boost::container::vector<empty>;
volatile ::boost::container::vector<empty> dummy;
#include <boost/container/allocator.hpp>
#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<test::movable_and_copyable_int> >;
template class boost::container::vector
< test::movable_and_copyable_int
, allocator<test::movable_and_copyable_int> >;
template class vec_iterator<int*, true >;
template class vec_iterator<int*, false>;
} //namespace boost {
} //namespace container {
int main()
{
::boost::container::vector<empty> dummy;
(void)dummy;
return 0;
}

View File

@ -7,15 +7,9 @@
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/container/allocator.hpp>
#include <boost/container/detail/flat_tree.hpp>
#include <boost/container/stable_vector.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/container/deque.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/container/detail/container_or_allocator_rebind.hpp>
#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::movable_and_copyable_int, test::movable_and_copyable_int> test_pair_t;
template class flat_map
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, test::simple_allocator< test_pair_t >
>;
template class flat_map
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, 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<test::movable_and_copyable_int>
, 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<test::movable_and_copyable_int>
, deque<test_pair_t, test::simple_allocator< test_pair_t > >
>;
template class flat_multimap
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, static_vector<test_pair_t, 10 >
>;
//As flat container iterators are typedefs for vector::[const_]iterator,
//no need to explicit instantiate them
}} //boost::container
#if (__cplusplus > 201103L)
#include <vector>
namespace boost{
namespace container{
template class flat_map
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, std::vector<test_pair_t>
>;
}} //boost::container
#endif
class recursive_flat_map
{
public:
@ -545,65 +473,10 @@ bool test_heterogeneous_lookups()
}}} //namespace boost::container::test
template<class VoidAllocatorOrContainer>
int test_map_variants()
{
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<int>::map_type MyMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::movable_int>::map_type MyMoveMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::movable_and_copyable_int>::map_type MyCopyMoveMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::copyable_int>::map_type MyCopyMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<int>::multimap_type MyMultiMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::movable_int>::multimap_type MyMoveMultiMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::movable_and_copyable_int>::multimap_type MyCopyMoveMultiMap;
typedef typename GetMapContainer<VoidAllocatorOrContainer>::template apply<test::copyable_int>::multimap_type MyCopyMultiMap;
typedef std::map<int, int> MyStdMap;
typedef std::multimap<int, int> MyStdMultiMap;
if (0 != test::map_test<
MyMap
,MyStdMap
,MyMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
if (0 != test::map_test<
MyMoveMap
,MyStdMap
,MyMoveMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
if (0 != test::map_test<
MyCopyMoveMap
,MyStdMap
,MyCopyMoveMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
if (0 != test::map_test<
MyCopyMap
,MyStdMap
,MyCopyMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
return 0;
}
int main()
{
using namespace boost::container::test;
/*
//Allocator argument container
{
flat_map<int, int> map_((flat_map<int, int>::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<void> >()){
std::cerr << "test_map_variants< std::allocator<void> > failed" << std::endl;
return 1;
}
// boost::container::allocator
if(test_map_variants< allocator<void> >()){
std::cerr << "test_map_variants< allocator<void> > failed" << std::endl;
return 1;
}
{
typedef std::map<int, int> MyStdMap;
typedef std::multimap<int, int> MyStdMultiMap;
if (0 != test::map_test
< GetMapContainer<std::allocator<void> >::apply<int>::map_type
, MyStdMap
, GetMapContainer<std::allocator<void> >::apply<int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<std::allocator<void> >" << std::endl;
return 1;
}
/*
if (0 != test::map_test
< GetMapContainer<new_allocator<void> >::apply<int>::map_type
, MyStdMap
, GetMapContainer<new_allocator<void> >::apply<int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::map_test
< GetMapContainer<new_allocator<void> >::apply<test::movable_int>::map_type
, MyStdMap
, GetMapContainer<new_allocator<void> >::apply<test::movable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::map_test
< GetMapContainer<new_allocator<void> >::apply<test::copyable_int>::map_type
, MyStdMap
, GetMapContainer<new_allocator<void> >::apply<test::copyable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::map_test
< GetMapContainer<new_allocator<void> >::apply<test::movable_and_copyable_int>::map_type
, MyStdMap
, GetMapContainer<new_allocator<void> >::apply<test::movable_and_copyable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void> >" << std::endl;
return 1;
}*/
}
/*
if(!boost::container::test::test_map_support_for_initialization_list_for<flat_map<int, int> >())
return 1;
@ -716,7 +628,7 @@ int main()
return 1;
}
}
*/
return 0;
}

View File

@ -13,11 +13,6 @@
#include <set>
#include <boost/container/flat_set.hpp>
#include <boost/container/stable_vector.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/container/deque.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/container/allocator.hpp>
#include <boost/container/detail/container_or_allocator_rebind.hpp>
#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::movable_and_copyable_int>
, test::simple_allocator<test::movable_and_copyable_int>
>;
template class flat_set
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, small_vector<test::movable_and_copyable_int, 10, allocator<test::movable_and_copyable_int> >
>;
//flat_multiset
template class flat_multiset
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, stable_vector<test::movable_and_copyable_int, test::simple_allocator<test::movable_and_copyable_int> >
>;
template class flat_multiset
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, deque<test::movable_and_copyable_int, test::simple_allocator< test::movable_and_copyable_int > >
>;
template class flat_multiset
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, static_vector<test::movable_and_copyable_int, 10 >
>;
//As flat container iterators are typedefs for vector::[const_]iterator,
//no need to explicit instantiate them
}} //boost::container
#if (__cplusplus > 201103L)
#include <vector>
namespace boost{
namespace container{
template class flat_set
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, std::vector<test::movable_and_copyable_int>
>;
}} //boost::container
#endif
//Test recursive structures
class recursive_flat_set
{
@ -558,62 +494,6 @@ struct GetSetContainer
};
};
template<class VoidAllocator>
int test_set_variants()
{
typedef typename GetSetContainer<VoidAllocator>::template apply<int>::set_type MySet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::movable_int>::set_type MyMoveSet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::movable_and_copyable_int>::set_type MyCopyMoveSet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::copyable_int>::set_type MyCopySet;
typedef typename GetSetContainer<VoidAllocator>::template apply<int>::multiset_type MyMultiSet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::movable_int>::multiset_type MyMoveMultiSet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::movable_and_copyable_int>::multiset_type MyCopyMoveMultiSet;
typedef typename GetSetContainer<VoidAllocator>::template apply<test::copyable_int>::multiset_type MyCopyMultiSet;
typedef std::set<int> MyStdSet;
typedef std::multiset<int> MyStdMultiSet;
if (0 != test::set_test<
MySet
,MyStdSet
,MyMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
if (0 != test::set_test<
MyMoveSet
,MyStdSet
,MyMoveMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
if (0 != test::set_test<
MyCopyMoveSet
,MyStdSet
,MyCopyMoveMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
if (0 != test::set_test<
MyCopySet
,MyStdSet
,MyCopyMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
return 0;
}
template<typename FlatSetType>
bool test_support_for_initialization_list_for()
{
@ -731,15 +611,54 @@ int main()
////////////////////////////////////
// Testing allocator implementations
////////////////////////////////////
// std::allocator
if(test_set_variants< std::allocator<void> >()){
std::cerr << "test_set_variants< std::allocator<void> > failed" << std::endl;
return 1;
}
// boost::container::allocator
if(test_set_variants< allocator<void> >()){
std::cerr << "test_set_variants< allocator<void> > failed" << std::endl;
return 1;
{
typedef std::set<int> MyStdSet;
typedef std::multiset<int> MyStdMultiSet;
if (0 != test::set_test
< GetSetContainer<std::allocator<void> >::apply<int>::set_type
, MyStdSet
, GetSetContainer<std::allocator<void> >::apply<int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<std::allocator<void> >" << std::endl;
return 1;
}
if (0 != test::set_test
< GetSetContainer<new_allocator<void> >::apply<int>::set_type
, MyStdSet
, GetSetContainer<new_allocator<void> >::apply<int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::set_test
< GetSetContainer<new_allocator<void> >::apply<test::movable_int>::set_type
, MyStdSet
, GetSetContainer<new_allocator<void> >::apply<test::movable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::set_test
< GetSetContainer<new_allocator<void> >::apply<test::copyable_int>::set_type
, MyStdSet
, GetSetContainer<new_allocator<void> >::apply<test::copyable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void> >" << std::endl;
return 1;
}
if (0 != test::set_test
< GetSetContainer<new_allocator<void> >::apply<test::movable_and_copyable_int>::set_type
, MyStdSet
, GetSetContainer<new_allocator<void> >::apply<test::movable_and_copyable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void> >" << std::endl;
return 1;
}
}
////////////////////////////////////

View File

@ -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();

View File

@ -168,16 +168,19 @@ int main ()
////////////////////////////////////
// Testing allocator implementations
////////////////////////////////////
// std:allocator
if(test_cont_variants< std::allocator<void> >()){
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
// int variants
if (test::list_test<list<int, std::allocator<int> >, true>())
return 1;
}
// boost::container::adaptive_pool
if(test_cont_variants< adaptive_pool<void> >()){
std::cerr << "test_cont_variants< adaptive_pool<void> > failed" << std::endl;
if (test::list_test<list<int>, true>())
return 1;
if (test::list_test<list<int, adaptive_pool<int> >, true>())
return 1;
if (test::list_test<list<test::movable_int>, true>())
return 1;
if (test::list_test<list<test::movable_and_copyable_int>, true>())
return 1;
if (test::list_test<list<test::copyable_int>, true>())
return 1;
}
////////////////////////////////////
// Emplace testing

View File

@ -25,34 +25,6 @@ using namespace boost::container;
typedef std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> 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::movable_and_copyable_int>
, test::simple_allocator< pair_t >
>;
template class map
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, adaptive_pool< pair_t >
>;
template class multimap
< test::movable_and_copyable_int
, test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, std::allocator< pair_t >
>;
}} //boost::container
class recursive_map
{
public:
@ -240,50 +212,6 @@ struct GetAllocatorMap
};
};
template<class VoidAllocator, boost::container::tree_type_enum tree_type_value>
int test_map_variants()
{
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<int>::map_type MyMap;
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<test::movable_int>::map_type MyMoveMap;
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<test::copyable_int>::map_type MyCopyMap;
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<int>::multimap_type MyMultiMap;
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<test::movable_int>::multimap_type MyMoveMultiMap;
typedef typename GetAllocatorMap<VoidAllocator, tree_type_value>::template apply<test::copyable_int>::multimap_type MyCopyMultiMap;
typedef std::map<int, int> MyStdMap;
typedef std::multimap<int, int> MyStdMultiMap;
if (0 != test::map_test<
MyMap
,MyStdMap
,MyMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
if (0 != test::map_test<
MyMoveMap
,MyStdMap
,MyMoveMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
return 1;
}
if (0 != test::map_test<
MyCopyMap
,MyStdMap
,MyCopyMultiMap
,MyStdMultiMap>()){
std::cout << "Error in map_test<MyBoostMap>" << 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<void>, red_black_tree >()){
std::cerr << "test_map_variants< std::allocator<void> > failed" << std::endl;
return 1;
}
// boost::container::adaptive_pool
if(test_map_variants< adaptive_pool<void>, red_black_tree >()){
std::cerr << "test_map_variants< adaptive_pool<void> > failed" << std::endl;
return 1;
}
{
typedef std::map<int, int> MyStdMap;
typedef std::multimap<int, int> MyStdMultiMap;
////////////////////////////////////
// Tree implementations
////////////////////////////////////
// AVL
if(test_map_variants< std::allocator<void>, avl_tree >()){
std::cerr << "test_map_variants< std::allocator<void>, avl_tree > failed" << std::endl;
return 1;
}
// SCAPEGOAT TREE
if(test_map_variants< std::allocator<void>, scapegoat_tree >()){
std::cerr << "test_map_variants< std::allocator<void>, scapegoat_tree > failed" << std::endl;
return 1;
}
// SPLAY TREE
if(test_map_variants< std::allocator<void>, splay_tree >()){
std::cerr << "test_map_variants< std::allocator<void>, splay_tree > failed" << std::endl;
return 1;
if (0 != test::map_test
< GetAllocatorMap<std::allocator<void>, red_black_tree>::apply<int>::map_type
, MyStdMap
, GetAllocatorMap<std::allocator<void>, red_black_tree>::apply<int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<std::allocator<void>, red_black_tree>" << std::endl;
return 1;
}
if (0 != test::map_test
< GetAllocatorMap<new_allocator<void>, avl_tree>::apply<int>::map_type
, MyStdMap
, GetAllocatorMap<new_allocator<void>, avl_tree>::apply<int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void>, avl_tree>" << std::endl;
return 1;
}
if (0 != test::map_test
< GetAllocatorMap<adaptive_pool<void>, scapegoat_tree>::apply<int>::map_type
, MyStdMap
, GetAllocatorMap<adaptive_pool<void>, scapegoat_tree>::apply<int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<adaptive_pool<void>, scapegoat_tree>" << std::endl;
return 1;
}
///////////
if (0 != test::map_test
< GetAllocatorMap<new_allocator<void>, splay_tree>::apply<test::movable_int>::map_type
, MyStdMap
, GetAllocatorMap<new_allocator<void>, splay_tree>::apply<test::movable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void>, splay_tree>" << std::endl;
return 1;
}
if (0 != test::map_test
< GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::map_type
, MyStdMap
, GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
return 1;
}
if (0 != test::map_test
< GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::map_type
, MyStdMap
, GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::multimap_type
, MyStdMultiMap>()) {
std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
return 1;
}
}
////////////////////////////////////

View File

@ -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;
};

View File

@ -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::movable_and_copyable_int>
, test::simple_allocator<test::movable_and_copyable_int>
>;
template class set
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, new_allocator<test::movable_and_copyable_int>
>;
//multiset
template class multiset
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, test::simple_allocator<test::movable_and_copyable_int>
>;
template class multiset
< test::movable_and_copyable_int
, std::less<test::movable_and_copyable_int>
, adaptive_pool<test::movable_and_copyable_int>
>;
}} //boost::container
//Test recursive structures
class recursive_set
{
@ -267,50 +234,6 @@ struct GetAllocatorSet
};
};
template<class VoidAllocator, boost::container::tree_type_enum tree_type_value>
int test_set_variants()
{
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<int>::set_type MySet;
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<test::movable_int>::set_type MyMoveSet;
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<test::copyable_int>::set_type MyCopySet;
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<int>::multiset_type MyMultiSet;
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<test::movable_int>::multiset_type MyMoveMultiSet;
typedef typename GetAllocatorSet<VoidAllocator, tree_type_value>::template apply<test::copyable_int>::multiset_type MyCopyMultiSet;
typedef std::set<int> MyStdSet;
typedef std::multiset<int> MyStdMultiSet;
if (0 != test::set_test<
MySet
,MyStdSet
,MyMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
if (0 != test::set_test<
MyMoveSet
,MyStdSet
,MyMoveMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
if (0 != test::set_test<
MyCopySet
,MyStdSet
,MyCopyMultiSet
,MyStdMultiSet>()){
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
return 1;
}
return 0;
}
void test_merge_from_different_comparison()
{
set<int> set1;
@ -443,34 +366,65 @@ int main ()
////////////////////////////////////
// Testing allocator implementations
////////////////////////////////////
// std:allocator
if(test_set_variants< std::allocator<void>, red_black_tree >()){
std::cerr << "test_set_variants< std::allocator<void> > failed" << std::endl;
return 1;
}
// boost::container::adaptive_pool
if(test_set_variants< adaptive_pool<void>, red_black_tree>()){
std::cerr << "test_set_variants< adaptive_pool<void> > failed" << std::endl;
return 1;
}
{
typedef std::set<int> MyStdSet;
typedef std::multiset<int> MyStdMultiSet;
////////////////////////////////////
// Tree implementations
////////////////////////////////////
// AVL
if(test_set_variants< std::allocator<void>, avl_tree >()){
std::cerr << "test_set_variants< std::allocator<void>, avl_tree > failed" << std::endl;
return 1;
}
// SCAPEGOAT TREE
if(test_set_variants< std::allocator<void>, scapegoat_tree >()){
std::cerr << "test_set_variants< std::allocator<void>, scapegoat_tree > failed" << std::endl;
return 1;
}
// SPLAY TREE
if(test_set_variants< std::allocator<void>, splay_tree >()){
std::cerr << "test_set_variants< std::allocator<void>, splay_tree > failed" << std::endl;
return 1;
if (0 != test::set_test
< GetAllocatorSet<std::allocator<void>, red_black_tree>::apply<int>::set_type
, MyStdSet
, GetAllocatorSet<std::allocator<void>, red_black_tree>::apply<int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<std::allocator<void>, red_black_tree>" << std::endl;
return 1;
}
if (0 != test::set_test
< GetAllocatorSet<new_allocator<void>, avl_tree>::apply<int>::set_type
, MyStdSet
, GetAllocatorSet<new_allocator<void>, avl_tree>::apply<int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void>, avl_tree>" << std::endl;
return 1;
}
if (0 != test::set_test
< GetAllocatorSet<adaptive_pool<void>, scapegoat_tree>::apply<int>::set_type
, MyStdSet
, GetAllocatorSet<adaptive_pool<void>, scapegoat_tree>::apply<int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<adaptive_pool<void>, scapegoat_tree>" << std::endl;
return 1;
}
///////////
if (0 != test::set_test
< GetAllocatorSet<new_allocator<void>, splay_tree>::apply<test::movable_int>::set_type
, MyStdSet
, GetAllocatorSet<new_allocator<void>, splay_tree>::apply<test::movable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void>, splay_tree>" << std::endl;
return 1;
}
if (0 != test::set_test
< GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::set_type
, MyStdSet
, GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void>, red_black_tree>" << std::endl;
return 1;
}
if (0 != test::set_test
< GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::set_type
, MyStdSet
, GetAllocatorSet<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::multiset_type
, MyStdMultiSet>()) {
std::cout << "Error in set_test<new_allocator<void>, red_black_tree>" << std::endl;
return 1;
}
}
////////////////////////////////////

View File

@ -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<test::movable_and_copyable_int> >;
template class boost::container::slist
< test::movable_and_copyable_int
, node_allocator<test::movable_and_copyable_int> >;
}}
class recursive_slist
{
public:
@ -65,28 +51,6 @@ struct GetAllocatorCont
};
};
template<class VoidAllocator>
int test_cont_variants()
{
typedef typename GetAllocatorCont<VoidAllocator>::template apply<int>::type MyCont;
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
if(test::list_test<MyCont, false>())
return 1;
if(test::list_test<MyMoveCont, false>())
return 1;
if(test::list_test<MyCopyMoveCont, false>())
return 1;
if(test::list_test<MyCopyMoveCont, false>())
return 1;
if(test::list_test<MyCopyCont, false>())
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<void> >()){
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
if (test::list_test<slist<int, std::allocator<int> >, false>())
return 1;
}
// boost::container::node_allocator
if(test_cont_variants< node_allocator<void> >()){
std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
if (test::list_test<slist<int>, false>())
return 1;
if (test::list_test<slist<int, node_allocator<int> >, false>())
return 1;
if (test::list_test<slist<test::movable_int>, false>())
return 1;
if (test::list_test<slist<test::movable_and_copyable_int>, false>())
return 1;
if (test::list_test<slist<test::copyable_int>, false>())
return 1;
}
////////////////////////////////////
// Emplace testing

View File

@ -18,32 +18,6 @@
#include <iostream>
namespace boost {
namespace container {
template class small_vector<char, 0>;
template class small_vector<char, 1>;
template class small_vector<char, 2>;
template class small_vector<char, 10>;
template class small_vector<int, 0>;
template class small_vector<int, 1>;
template class small_vector<int, 2>;
template class small_vector<int, 10>;
//Explicit instantiation to detect compilation errors
template class boost::container::small_vector
< test::movable_and_copyable_int
, 10
, test::simple_allocator<test::movable_and_copyable_int> >;
template class boost::container::small_vector
< test::movable_and_copyable_int
, 10
, allocator<test::movable_and_copyable_int> >;
}}
struct boost_container_small_vector;
namespace boost { namespace container { namespace test {

View File

@ -26,22 +26,6 @@
using namespace boost::container;
namespace boost {
namespace container {
//Explicit instantiation to detect compilation errors
template class stable_vector<test::movable_and_copyable_int,
test::simple_allocator<test::movable_and_copyable_int> >;
template class stable_vector
< test::movable_and_copyable_int
, node_allocator<test::movable_and_copyable_int> >;
template class stable_vector_iterator<int*, false>;
template class stable_vector_iterator<int*, true >;
}}
class recursive_vector
{
public:

View File

@ -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<int, 10>;
}}
template <typename T, size_t N>
void test_ctor_ndc()

View File

@ -31,28 +31,6 @@
using namespace boost::container;
typedef test::simple_allocator<char> SimpleCharAllocator;
typedef basic_string<char, std::char_traits<char>, SimpleCharAllocator> SimpleString;
typedef test::simple_allocator<SimpleString> SimpleStringAllocator;
typedef test::simple_allocator<wchar_t> SimpleWCharAllocator;
typedef basic_string<wchar_t, std::char_traits<wchar_t>, SimpleWCharAllocator> SimpleWString;
typedef test::simple_allocator<SimpleWString> SimpleWStringAllocator;
namespace boost {
namespace container {
//Explicit instantiations of container::basic_string
template class basic_string<char, std::char_traits<char>, SimpleCharAllocator>;
template class basic_string<wchar_t, std::char_traits<wchar_t>, SimpleWCharAllocator>;
template class basic_string<char, std::char_traits<char>, std::allocator<char> >;
template class basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >;
//Explicit instantiation of container::vectors of container::strings
template class vector<SimpleString, SimpleStringAllocator>;
template class vector<SimpleWString, SimpleWStringAllocator>;
}}
struct StringEqual
{
template<class Str1, class Str2>

View File

@ -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<test::movable_and_copyable_int> >;
template class boost::container::vector
< test::movable_and_copyable_int
, allocator<test::movable_and_copyable_int> >;
template class vec_iterator<int*, true >;
template class vec_iterator<int*, false>;
}}
int test_expand_bwd()
{
//Now test all back insertion possibilities