diff --git a/unittests/structs_minimal.cpp b/unittests/structs_minimal.cpp index 5dfbf660..877c65f6 100644 --- a/unittests/structs_minimal.cpp +++ b/unittests/structs_minimal.cpp @@ -169,6 +169,41 @@ void load_minimal( Archive const &, Issue79Struct & val, std::int32_t const & xx val.x = xx; } +struct Issue79StructInternal +{ + Issue79StructInternal() = default; + Issue79StructInternal( std::int32_t xx ) : x(xx) {} + std::int32_t x; + + template ::value || + std::is_same::value> = cereal::traits::sfinae> + std::string save_minimal( Archive const & ) const + { + return std::to_string( x ); + } + + template ::value || + std::is_same::value> = cereal::traits::sfinae> + void load_minimal( Archive const &, std::string const & str ) + { + x = std::stoi( str ); + } + + template ::value || + std::is_same::value> = cereal::traits::sfinae> + std::int32_t save_minimal( Archive const & ) const + { + return x; + } + + template ::value || + std::is_same::value> = cereal::traits::sfinae> + void load_minimal( Archive const &, std::int32_t const & xx ) + { + x = xx; + } +}; + template void test_structs_minimal() { @@ -181,22 +216,26 @@ void test_structs_minimal() random_value(gen), random_value(gen) % 2 ? true : false }; Issue79Struct o_struct2 = { random_value(gen) }; + Issue79StructInternal o_struct3 = { random_value(gen) }; std::ostringstream os; { OArchive oar(os); oar( o_struct ); oar( o_struct2 ); + oar( o_struct3 ); } decltype(o_struct) i_struct; decltype(o_struct2) i_struct2; + decltype(o_struct3) i_struct3; std::istringstream is(os.str()); { IArchive iar(is); iar( i_struct ); iar( i_struct2 ); + iar( i_struct3 ); } BOOST_CHECK(o_struct.mm.x == i_struct.mm.x); @@ -206,6 +245,8 @@ void test_structs_minimal() BOOST_CHECK(o_struct.nmmv.x == i_struct.nmmv.x); BOOST_CHECK(o_struct2.x == i_struct2.x); + + BOOST_CHECK(o_struct3.x == i_struct3.x); } }