/* Copyright 2016-2017 Joaquin M Lopez Munoz. * 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/poly_collection for library home page. */ #include "test_registration.hpp" #include #include #include "any_types.hpp" #include "base_types.hpp" #include "function_types.hpp" #include "test_utilities.hpp" using namespace test_utilities; template void test_registration() { using unregistered_type=boost::poly_collection::unregistered_type; { PolyCollection p; const PolyCollection& cp=p; BOOST_TEST(!p.is_registered(typeid(Type))); BOOST_TEST(!p.template is_registered()); check_throw( [&]{(void)p.begin(typeid(Type));}, [&]{(void)p.end(typeid(Type));}, [&]{(void)cp.begin(typeid(Type));}, [&]{(void)cp.end(typeid(Type));}, [&]{(void)p.cbegin(typeid(Type));}, [&]{(void)p.cend(typeid(Type));}, [&]{(void)p.template begin();}, [&]{(void)p.template end();}, [&]{(void)cp.template begin();}, [&]{(void)cp.template end();}, [&]{(void)p.template cbegin();}, [&]{(void)p.template cend();}, [&]{(void)p.segment(typeid(Type));}, [&]{(void)cp.segment(typeid(Type));}, [&]{(void)p.template segment();}, [&]{(void)cp.template segment();}, [&]{(void)cp.empty(typeid(Type));}, [&]{(void)cp.size(typeid(Type));}, [&]{(void)cp.max_size(typeid(Type));}, [&]{(void)p.reserve(typeid(Type),0);}, [&]{(void)cp.capacity(typeid(Type));}, [&]{(void)p.shrink_to_fit(typeid(Type));}, [&]{(void)p.clear(typeid(Type));}, [&]{(void)cp.template empty();}, [&]{(void)cp.template size();}, [&]{(void)cp.template max_size();}, /* reserve omitted as it actually registers the type */ [&]{(void)cp.template capacity();}, [&]{(void)p.template shrink_to_fit();}, [&]{(void)p.template clear();}); p.register_types(); p.template register_types<>(); BOOST_TEST(!p.is_registered(typeid(Type))); p.template register_types(); BOOST_TEST(p.is_registered(typeid(Type))); BOOST_TEST(p.template is_registered()); (void)p.end(typeid(Type)); (void)cp.begin(typeid(Type)); (void)cp.end(typeid(Type)); (void)p.cbegin(typeid(Type)); (void)p.cend(typeid(Type)); (void)p.template begin(); (void)p.template end(); (void)cp.template begin(); (void)cp.template end(); (void)cp.template cbegin(); (void)cp.template cend(); (void)cp.empty(typeid(Type)); (void)cp.size(typeid(Type)); (void)cp.max_size(typeid(Type)); (void)p.reserve(typeid(Type),0); (void)cp.capacity(typeid(Type)); (void)p.shrink_to_fit(typeid(Type)); (void)p.clear(typeid(Type)); (void)cp.template empty(); (void)cp.template size(); (void)cp.template max_size(); /* reserve omitted */ (void)cp.template capacity(); (void)p.template shrink_to_fit(); (void)p.template clear(); } { PolyCollection p; p.template reserve(0); BOOST_TEST(p.is_registered(typeid(Type))); } { PolyCollection p; p.template register_types(); BOOST_TEST(p.is_registered(typeid(Type))); BOOST_TEST( std::distance( p.segment_traversal().begin(),p.segment_traversal().end())==1); } } void test_registration() { test_registration(); test_registration(); test_registration(); }