diff options
Diffstat (limited to 'libs/accumulators/test/count.cpp')
-rw-r--r-- | libs/accumulators/test/count.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libs/accumulators/test/count.cpp b/libs/accumulators/test/count.cpp index 01d48a5de5..e2f4436b6b 100644 --- a/libs/accumulators/test/count.cpp +++ b/libs/accumulators/test/count.cpp @@ -7,6 +7,9 @@ #include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics/stats.hpp> #include <boost/accumulators/statistics/count.hpp> +#include <sstream> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> using namespace boost; using namespace unit_test; @@ -36,6 +39,31 @@ void test_stat() } /////////////////////////////////////////////////////////////////////////////// +// test_persistency +// +void test_persistency() +{ + // "persistent" storage + std::stringstream ss; + { + accumulator_set<int, stats<tag::count> > acc; + acc(1); + acc(1); + acc(1); + acc(1); + BOOST_CHECK_EQUAL(4u, count(acc)); + boost::archive::text_oarchive oa(ss); + acc.serialize(oa, 0); + } + accumulator_set<int, stats<tag::count> > acc; + BOOST_CHECK_EQUAL(0u, count(acc)); + boost::archive::text_iarchive ia(ss); + acc.serialize(ia, 0); + BOOST_CHECK_EQUAL(4u, count(acc)); + +} + +/////////////////////////////////////////////////////////////////////////////// // init_unit_test_suite // test_suite* init_unit_test_suite( int argc, char* argv[] ) @@ -43,6 +71,7 @@ test_suite* init_unit_test_suite( int argc, char* argv[] ) test_suite *test = BOOST_TEST_SUITE("count test"); test->add(BOOST_TEST_CASE(&test_stat)); + test->add(BOOST_TEST_CASE(&test_persistency)); return test; } |