// ----------------------------------------------------------- // Copyright (c) 2001 Jeremy Siek // Copyright (c) 2003-2006 Gennaro Prota // // Copyright (c) 2015 Seth Heeren // // 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) // // ----------------------------------------------------------- #include "boost/config.hpp" #if !defined (BOOST_NO_STRINGSTREAM) # include #endif #include "bitset_test.hpp" #include #include // Codewarrior 8.3 for Win fails without this. // Thanks Howard Hinnant ;) #if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x # pragma parse_func_templ off #endif #if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE # define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS #endif #include #include #include #include #include namespace { template struct SerializableType { boost::dynamic_bitset x; private: friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int) { ar & BOOST_SERIALIZATION_NVP(x); } }; template void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) { SerializableType a; for (int i=0; i<128; ++i) a.x.resize(11*i, i%2); #if !defined (BOOST_NO_STRINGSTREAM) std::stringstream ss; // test serialization { OArchive oa(ss); oa << BOOST_SERIALIZATION_NVP(a); } // test de-serialization { IArchive ia(ss); SerializableType b; ia >> BOOST_SERIALIZATION_NVP(b); assert(a.x == b.x); } #else # error "TODO implement file-based test path?" #endif } template void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) { test_serialization(); } template void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) { test_serialization(); } } template void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) { test_binary_archive(); test_xml_archive(); } int main() { run_test_cases(); run_test_cases(); run_test_cases(); run_test_cases(); # ifdef BOOST_HAS_LONG_LONG run_test_cases< ::boost::ulong_long_type>(); # endif return boost::report_errors(); }