1 // Copyright 2019 Hans Dembinski
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/assert.hpp>
8 #include <boost/core/lightweight_test.hpp>
9 #include <boost/histogram/accumulators.hpp>
10 #include <boost/histogram/serialization.hpp>
11 #include <boost/histogram/weight.hpp>
12 #include "throw_exception.hpp"
13 #include "utility_serialization.hpp"
15 using namespace boost::histogram;
17 int main(int argc, char** argv) {
18 BOOST_ASSERT(argc == 2);
22 const auto filename = join(argv[1], "accumulators_serialization_test_mean_v0.xml");
23 accumulators::mean<> a;
24 load_xml(filename, a);
25 BOOST_TEST_EQ(a.count(), 3);
26 BOOST_TEST_EQ(a.value(), 2);
27 BOOST_TEST_EQ(a.variance(), 0.5);
32 const auto filename = join(argv[1], "accumulators_serialization_test_mean.xml");
33 accumulators::mean<> a;
37 print_xml(filename, a);
39 accumulators::mean<> b;
40 BOOST_TEST_NOT(a == b);
41 load_xml(filename, b);
47 const auto filename = join(argv[1], "accumulators_serialization_test_sum.xml");
48 accumulators::sum<> a;
51 print_xml(filename, a);
53 accumulators::sum<> b;
54 BOOST_TEST_NOT(a == b);
55 load_xml(filename, b);
62 join(argv[1], "accumulators_serialization_test_weighted_mean.xml");
63 accumulators::weighted_mean<> a;
67 print_xml(filename, a);
69 accumulators::weighted_mean<> b;
70 BOOST_TEST_NOT(a == b);
71 load_xml(filename, b);
78 join(argv[1], "accumulators_serialization_test_weighted_sum.xml");
79 accumulators::weighted_sum<> a;
82 print_xml(filename, a);
84 accumulators::weighted_sum<> b;
85 BOOST_TEST_NOT(a == b);
86 load_xml(filename, b);
90 return boost::report_errors();