]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/histogram/test/histogram_serialization_test.cpp
1 // Copyright 2018 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)
8 #include <boost/core/lightweight_test.hpp>
9 #include <boost/histogram/axis.hpp>
10 #include <boost/histogram/axis/ostream.hpp>
11 #include <boost/histogram/ostream.hpp>
12 #include <boost/histogram/serialization.hpp>
15 #include "throw_exception.hpp"
16 #include "utility_histogram.hpp"
17 #include "utility_serialization.hpp"
19 using namespace boost::histogram
;
21 template <typename Tag
>
22 void run_tests(const std::string
& filename
) {
23 // histogram_serialization
24 namespace tr
= axis::transform
;
25 using def
= use_default
;
26 using axis::option::none_t
;
28 make(Tag(), axis::regular
<double, def
, def
, none_t
>(1, -1, 1, "reg"),
29 axis::circular
<float, def
, none_t
>(1, 0.0, 1.0, "cir"),
30 axis::regular
<double, tr::log
, def
, none_t
>(1, 1, std::exp(2), "reg-log"),
31 axis::regular
<double, tr::pow
, std::vector
<int>, axis::option::overflow_t
>(
32 tr::pow(0.5), 1, 1, 100, {1, 2, 3}),
33 axis::variable
<double, def
, none_t
>({1.5, 2.5}, "var"),
34 axis::category
<int, def
, none_t
>{3, 1},
35 axis::integer
<int, axis::null_type
, none_t
>(1, 2));
36 a(0.5, 0.2, 2, 20, 2.2, 1, 1);
37 print_xml(filename
, a
);
39 auto b
= decltype(a
)();
41 load_xml(filename
, b
);
45 int main(int argc
, char** argv
) {
47 run_tests
<static_tag
>(join(argv
[1], "histogram_serialization_test_static.xml"));
48 run_tests
<dynamic_tag
>(join(argv
[1], "histogram_serialization_test_dynamic.xml"));
49 return boost::report_errors();