#include "common.hpp" template void test_multimap() { std::random_device rd; std::mt19937 gen(rd()); for(int ii=0; ii<100; ++ii) { std::multimap o_podmultimap; for(int j=0; j<100; ++j) { auto key = random_value(gen); o_podmultimap.insert({key, random_value(gen)}); o_podmultimap.insert({key, random_value(gen)}); } std::multimap o_isermultimap; for(int j=0; j<100; ++j) { auto key = random_value(gen); o_isermultimap.insert({key, { random_value(gen), random_value(gen) }}); o_isermultimap.insert({key, { random_value(gen), random_value(gen) }}); } std::multimap o_isplmultimap; for(int j=0; j<100; ++j) { auto key = random_value(gen); o_isplmultimap.insert({key, { random_value(gen), random_value(gen) }}); o_isplmultimap.insert({key, { random_value(gen), random_value(gen) }}); } std::multimap o_esermultimap; for(int j=0; j<100; ++j) { auto key = random_value(gen); o_esermultimap.insert({key, { random_value(gen), random_value(gen) }}); o_esermultimap.insert({key, { random_value(gen), random_value(gen) }}); } std::multimap o_esplmultimap; for(int j=0; j<100; ++j) { auto key = random_value(gen); o_esplmultimap.insert({key, { random_value(gen), random_value(gen) }}); o_esplmultimap.insert({key, { random_value(gen), random_value(gen) }}); } std::ostringstream os; { OArchive oar(os); oar(o_podmultimap); oar(o_isermultimap); oar(o_isplmultimap); oar(o_esermultimap); oar(o_esplmultimap); } std::multimap i_podmultimap; std::multimap i_isermultimap; std::multimap i_isplmultimap; std::multimap i_esermultimap; std::multimap i_esplmultimap; std::istringstream is(os.str()); { IArchive iar(is); iar(i_podmultimap); iar(i_isermultimap); iar(i_isplmultimap); iar(i_esermultimap); iar(i_esplmultimap); } #define MULTIMAP_CHECK(InMap, OutMap) \ for( auto & pair : OutMap ) \ { \ auto const count = InMap.count( pair.first ); \ BOOST_CHECK_EQUAL( count, OutMap.count( pair.first ) ); \ auto find = InMap.find( pair.first ); \ bool found = false; \ for( size_t i = 0; i < count; ++i, ++find ) \ found |= find->second == pair.second; \ BOOST_CHECK( found ); \ } MULTIMAP_CHECK( i_podmultimap, o_podmultimap ); MULTIMAP_CHECK( i_isermultimap, o_isermultimap ); MULTIMAP_CHECK( i_isplmultimap, o_isplmultimap ); MULTIMAP_CHECK( i_esermultimap, o_esermultimap ); MULTIMAP_CHECK( i_esplmultimap, o_esplmultimap ); #undef MULTIMAP_CHECK } } BOOST_AUTO_TEST_CASE( binary_multimap ) { test_multimap(); } BOOST_AUTO_TEST_CASE( portable_binary_multimap ) { test_multimap(); } BOOST_AUTO_TEST_CASE( xml_multimap ) { test_multimap(); } BOOST_AUTO_TEST_CASE( json_multimap ) { test_multimap(); }