1 | // (C) Copyright Eric Niebler 2005. |
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/test/tools/floating_point_comparison.hpp> |
8 | #include <boost/accumulators/accumulators.hpp> |
9 | #include <boost/accumulators/statistics/stats.hpp> |
10 | #include <boost/accumulators/statistics/with_error.hpp> |
11 | #include <boost/accumulators/statistics/error_of_mean.hpp> |
12 | |
13 | using namespace boost; |
14 | using namespace unit_test; |
15 | using namespace accumulators; |
16 | |
17 | /////////////////////////////////////////////////////////////////////////////// |
18 | // test_stat |
19 | // |
20 | void test_stat() |
21 | { |
22 | accumulator_set<double, stats<tag::error_of<tag::mean(lazy)> > > acc; |
23 | acc(1.1); |
24 | acc(1.2); |
25 | acc(1.3); |
26 | BOOST_CHECK_CLOSE(0.057735, accumulators::error_of<tag::mean(lazy)>(acc), 1e-4); |
27 | |
28 | accumulator_set<double, stats<tag::error_of<tag::mean(immediate)> > > acc2; |
29 | acc2(1.1); |
30 | acc2(1.2); |
31 | acc2(1.3); |
32 | BOOST_CHECK_CLOSE(0.057735, accumulators::error_of<tag::mean(immediate)>(acc2), 1e-4); |
33 | |
34 | accumulator_set<double, stats<with_error<tag::mean(lazy)> > > acc3; |
35 | acc3(1.1); |
36 | acc3(1.2); |
37 | acc3(1.3); |
38 | BOOST_CHECK_CLOSE(0.057735, accumulators::error_of<tag::mean(lazy)>(acc3), 1e-4); |
39 | |
40 | accumulator_set<double, stats<with_error<tag::mean(immediate)> > > acc4; |
41 | acc4(1.1); |
42 | acc4(1.2); |
43 | acc4(1.3); |
44 | BOOST_CHECK_CLOSE(0.057735, accumulators::error_of<tag::mean(immediate)>(acc4), 1e-4); |
45 | } |
46 | |
47 | /////////////////////////////////////////////////////////////////////////////// |
48 | // init_unit_test_suite |
49 | // |
50 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
51 | { |
52 | test_suite *test = BOOST_TEST_SUITE("mean test" ); |
53 | |
54 | test->add(BOOST_TEST_CASE(&test_stat)); |
55 | |
56 | return test; |
57 | } |
58 | |