////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// #include #include "vector_test.hpp" #include "movable_int.hpp" #include "propagate_allocator_test.hpp" #include "default_init_test.hpp" #include #include #include #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 , test::dummy_test_allocator >; template class boost::container::small_vector < test::movable_and_copyable_int , 10 , std::allocator >; template class boost::container::small_vector < test::movable_and_copyable_int , 10 , allocator >; template class boost::container::small_vector < test::movable_and_copyable_int , 10 , adaptive_pool >; template class boost::container::small_vector < test::movable_and_copyable_int , 10 , node_allocator >; }} struct boost_container_small_vector; namespace boost { namespace container { namespace test { template<> struct alloc_propagate_base { template struct apply { typedef boost::container::small_vector type; }; }; }}} //namespace boost::container::test bool test_small_vector_base_test() { typedef boost::container::small_vector_base smb_t; { typedef boost::container::small_vector sm5_t; sm5_t sm5; smb_t &smb = sm5; smb.push_back(1); sm5_t sm5_copy(sm5); sm5_copy.push_back(1); if (!boost::container::test::CheckEqualContainers(sm5, smb)) return false; } { typedef boost::container::small_vector sm7_t; sm7_t sm7; smb_t &smb = sm7; smb.push_back(2); sm7_t sm7_copy(sm7); sm7_copy.push_back(2); if (!boost::container::test::CheckEqualContainers(sm7, smb)) return false; } return true; } int main() { using namespace boost::container; /* typedef small_vector::storage_test storage_test; std::cout << "needed_extra_storages: " << storage_test::needed_extra_storages << '\n'; std::cout << "needed_bytes: " << storage_test::needed_bytes << '\n'; std::cout << "header_bytes: " << storage_test::header_bytes << '\n'; std::cout << "s_start: " << storage_test::s_start << '\n'; //char std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "\n"; //short std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; std::cout << "sizeof(small_vector): " << sizeof(small_vector) << " extra: " << small_vector::needed_extra_storages << " internal storage: " << small_vector::internal_capacity() << '\n'; */ if(test::vector_test< small_vector >()) return 1; if(test::vector_test< small_vector >()) return 1; //////////////////////////////////// // Default init test //////////////////////////////////// if(!test::default_init_test< vector > >()){ std::cerr << "Default init test failed" << std::endl; return 1; } //////////////////////////////////// // Emplace testing //////////////////////////////////// const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE); if(!boost::container::test::test_emplace< vector, Options>()){ return 1; } //////////////////////////////////// // Allocator propagation testing //////////////////////////////////// if(!boost::container::test::test_propagate_allocator()){ return 1; } //////////////////////////////////// // Initializer lists testing //////////////////////////////////// if(!boost::container::test::test_vector_methods_with_initializer_list_as_argument_for< boost::container::vector >()) { return 1; } //////////////////////////////////// // Small vector base //////////////////////////////////// if (!test_small_vector_base_test()){ return 1; } return 0; }