1 // Copyright (c) 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 // This test is inspired by the corresponding boost/beast test of detail_variant.
9 #include <boost/assert.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/histogram/axis/integer.hpp>
12 #include <boost/histogram/axis/ostream.hpp>
13 #include <boost/histogram/axis/regular.hpp>
14 #include <boost/histogram/axis/variant.hpp>
15 #include <boost/histogram/serialization.hpp>
16 #include "throw_exception.hpp"
17 #include "utility_axis.hpp"
18 #include "utility_serialization.hpp"
20 using namespace boost::histogram::axis;
22 int main(int argc, char** argv) {
23 BOOST_ASSERT(argc == 2);
25 const auto filename = join(argv[1], "axis_variant_serialization_test.xml");
30 variant<I, R> a(I(0, 3));
31 variant<I, R> b(R(1, 0, 1));
32 print_xml(filename, b);
34 load_xml(filename, a);
37 variant<I> c; // load incompatible version
38 BOOST_TEST_THROWS(load_xml(filename, c), std::runtime_error);
40 return boost::report_errors();