]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/accumulators/test/rolling_count.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / accumulators / test / rolling_count.cpp
index fef132c9a865a2ead76967d176c7a2893e5c4a46..a1b6b6fe8cc948e4172e502f1d88813d66243839 100644 (file)
@@ -7,6 +7,9 @@
 #include <boost/accumulators/accumulators.hpp>
 #include <boost/accumulators/statistics/stats.hpp>
 #include <boost/accumulators/statistics/rolling_count.hpp>
+#include <sstream>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
 
 using namespace boost;
 using namespace unit_test;
@@ -37,6 +40,30 @@ void test_stat()
     BOOST_CHECK_EQUAL(3u, rolling_count(acc));
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// test_persistency
+//
+void test_persistency()
+{
+    std::stringstream ss;
+    {
+        accumulator_set<int, stats<tag::rolling_count> > acc(tag::rolling_window::window_size = 3);
+        acc(1);
+        acc(1);
+        acc(1);
+        acc(1);
+        acc(1);
+        acc(1);
+        BOOST_CHECK_EQUAL(3u, rolling_count(acc));
+        boost::archive::text_oarchive oa(ss);
+        acc.serialize(oa, 0);
+    }
+    accumulator_set<int, stats<tag::rolling_count> > acc(tag::rolling_window::window_size = 3);
+    boost::archive::text_iarchive ia(ss);
+    acc.serialize(ia, 0);
+    BOOST_CHECK_EQUAL(3u, rolling_count(acc));
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // init_unit_test_suite
 //
@@ -45,6 +72,7 @@ test_suite* init_unit_test_suite( int argc, char* argv[] )
     test_suite *test = BOOST_TEST_SUITE("rolling count test");
 
     test->add(BOOST_TEST_CASE(&test_stat));
+    test->add(BOOST_TEST_CASE(&test_persistency));
 
     return test;
 }