]>
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 | ||
7 | #include <array> | |
92f5a8d4 | 8 | #include <boost/core/lightweight_test.hpp> |
1e59de90 | 9 | #include <boost/histogram/accumulators/count.hpp> |
92f5a8d4 TL |
10 | #include <boost/histogram/accumulators/thread_safe.hpp> |
11 | #include <boost/histogram/serialization.hpp> | |
12 | #include <boost/histogram/storage_adaptor.hpp> | |
1e59de90 | 13 | #include <cassert> |
92f5a8d4 TL |
14 | #include <map> |
15 | #include <vector> | |
16 | #include "throw_exception.hpp" | |
17 | #include "utility_serialization.hpp" | |
18 | ||
19 | using namespace boost::histogram; | |
20 | ||
21 | template <typename T> | |
22 | void test_serialization(const std::string& filename) { | |
23 | auto a = storage_adaptor<T>(); | |
24 | a.reset(3); | |
25 | a[1] += 1; | |
26 | a[2] += 2; | |
27 | print_xml(filename, a); | |
28 | ||
29 | auto b = storage_adaptor<T>(); | |
30 | BOOST_TEST_NOT(a == b); | |
31 | load_xml(filename, b); | |
32 | BOOST_TEST(a == b); | |
33 | } | |
34 | ||
35 | int main(int argc, char** argv) { | |
20effc67 | 36 | assert(argc == 2); |
92f5a8d4 TL |
37 | |
38 | test_serialization<std::vector<int>>( | |
39 | join(argv[1], "storage_adaptor_serialization_test_vector_int.xml")); | |
40 | test_serialization<std::array<unsigned, 10>>( | |
41 | join(argv[1], "storage_adaptor_serialization_test_array_unsigned.xml")); | |
42 | test_serialization<std::map<std::size_t, double>>( | |
43 | join(argv[1], "storage_adaptor_serialization_test_map_double.xml")); | |
1e59de90 TL |
44 | test_serialization<std::vector<accumulators::count<int, true>>>( |
45 | join(argv[1], "storage_adaptor_serialization_test_vector_thread_safe_int.xml")); | |
46 | #include <boost/histogram/detail/ignore_deprecation_warning_begin.hpp> | |
92f5a8d4 TL |
47 | test_serialization<std::vector<accumulators::thread_safe<int>>>( |
48 | join(argv[1], "storage_adaptor_serialization_test_vector_thread_safe_int.xml")); | |
1e59de90 | 49 | #include <boost/histogram/detail/ignore_deprecation_warning_end.hpp> |
92f5a8d4 TL |
50 | |
51 | return boost::report_errors(); | |
52 | } |