]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/accumulators/test/rolling_sum.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / 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)
5
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>
10
11 using namespace boost;
12 using namespace unit_test;
13 using namespace accumulators;
14
15 ///////////////////////////////////////////////////////////////////////////////
16 // test_stat
17 //
18 void test_stat()
19 {
20 accumulator_set<int, stats<tag::rolling_sum> > acc(tag::rolling_window::window_size = 3);
21
22 BOOST_CHECK_EQUAL(0, rolling_sum(acc));
23
24 acc(1);
25 BOOST_CHECK_EQUAL(1, rolling_sum(acc));
26
27 acc(2);
28 BOOST_CHECK_EQUAL(3, rolling_sum(acc));
29
30 acc(3);
31 BOOST_CHECK_EQUAL(6, rolling_sum(acc));
32
33 acc(4);
34 BOOST_CHECK_EQUAL(9, rolling_sum(acc));
35
36 acc(5);
37 BOOST_CHECK_EQUAL(12, rolling_sum(acc));
38 }
39
40 ///////////////////////////////////////////////////////////////////////////////
41 // init_unit_test_suite
42 //
43 test_suite* init_unit_test_suite( int argc, char* argv[] )
44 {
45 test_suite *test = BOOST_TEST_SUITE("rolling sum test");
46
47 test->add(BOOST_TEST_CASE(&test_stat));
48
49 return test;
50 }