]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/accumulators/test/rolling_sum.cpp
1 // (C) Copyright Eric Niebler 2008.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/test/unit_test.hpp>
7 #include <boost/accumulators/accumulators.hpp>
8 #include <boost/accumulators/statistics/stats.hpp>
9 #include <boost/accumulators/statistics/rolling_sum.hpp>
11 #include <boost/archive/text_oarchive.hpp>
12 #include <boost/archive/text_iarchive.hpp>
14 using namespace boost
;
15 using namespace unit_test
;
16 using namespace accumulators
;
18 ///////////////////////////////////////////////////////////////////////////////
23 accumulator_set
<int, stats
<tag::rolling_sum
> > acc(tag::rolling_window::window_size
= 3);
25 BOOST_CHECK_EQUAL(0, rolling_sum(acc
));
28 BOOST_CHECK_EQUAL(1, rolling_sum(acc
));
31 BOOST_CHECK_EQUAL(3, rolling_sum(acc
));
34 BOOST_CHECK_EQUAL(6, rolling_sum(acc
));
37 BOOST_CHECK_EQUAL(9, rolling_sum(acc
));
40 BOOST_CHECK_EQUAL(12, rolling_sum(acc
));
43 ///////////////////////////////////////////////////////////////////////////////
46 void test_persistency()
50 accumulator_set
<int, stats
<tag::rolling_sum
> > acc(tag::rolling_window::window_size
= 3);
56 BOOST_CHECK_EQUAL(12, rolling_sum(acc
));
57 boost::archive::text_oarchive
oa(ss
);
60 accumulator_set
<int, stats
<tag::rolling_sum
> > acc(tag::rolling_window::window_size
= 3);
61 boost::archive::text_iarchive
ia(ss
);
63 BOOST_CHECK_EQUAL(12, rolling_sum(acc
));
66 ///////////////////////////////////////////////////////////////////////////////
67 // init_unit_test_suite
69 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
71 test_suite
*test
= BOOST_TEST_SUITE("rolling sum test");
73 test
->add(BOOST_TEST_CASE(&test_stat
));
74 test
->add(BOOST_TEST_CASE(&test_persistency
));