#include "common.hpp" template void test_complex() { std::random_device rd; std::mt19937 gen(rd()); auto rngF = [&](){ return random_value(gen); }; auto rngD = [&](){ return random_value(gen); }; auto rngLD = [&](){ return random_value(gen); }; for(int ii=0; ii<100; ++ii) { std::complex o_float( rngF(), rngF() ); std::complex o_double( rngD(), rngD() ); std::complex o_ldouble( rngLD(), rngLD() ); std::ostringstream os; { OArchive oar(os); oar(o_float); oar(o_double); oar(o_ldouble); } std::complex i_float; std::complex i_double; std::complex i_ldouble; std::istringstream is(os.str()); { IArchive iar(is); iar(i_float); iar(i_double); iar(i_ldouble); } BOOST_CHECK_EQUAL( o_float, i_float ); BOOST_CHECK_CLOSE( o_double.real(), i_double.real(), 1e-5); BOOST_CHECK_CLOSE( o_double.imag(), i_double.imag(), 1e-5); BOOST_CHECK_CLOSE( o_ldouble.real(), i_ldouble.real(), 1e-5); BOOST_CHECK_CLOSE( o_ldouble.imag(), i_ldouble.imag(), 1e-5); } } BOOST_AUTO_TEST_CASE( binary_complex ) { test_complex(); } BOOST_AUTO_TEST_CASE( portable_binary_complex ) { test_complex(); } BOOST_AUTO_TEST_CASE( xml_complex ) { test_complex(); } BOOST_AUTO_TEST_CASE( json_complex ) { test_complex(); }