]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // Copyright 2018 Hans Dembinski |
2 | // | |
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) | |
6 | ||
20effc67 | 7 | #include <cassert> |
92f5a8d4 TL |
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> | |
13 | #include <cmath> | |
14 | #include <string> | |
15 | #include "throw_exception.hpp" | |
16 | #include "utility_histogram.hpp" | |
17 | #include "utility_serialization.hpp" | |
18 | ||
19 | using namespace boost::histogram; | |
20 | ||
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; | |
27 | auto a = | |
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); | |
38 | ||
39 | auto b = decltype(a)(); | |
40 | BOOST_TEST_NE(a, b); | |
41 | load_xml(filename, b); | |
42 | BOOST_TEST_EQ(a, b); | |
43 | } | |
44 | ||
45 | int main(int argc, char** argv) { | |
20effc67 | 46 | assert(argc == 2); |
92f5a8d4 TL |
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(); | |
50 | } |