histogram/test/histogram_serialization_test.cpp
Hans Dembinski 9abbe46e3d
CI & doc update, removed multiprecision::cpp_int, simpler axis implementation, use_default to set default options
* Travis uses b2 and codecov now
* replacing boost::multiprecision with custom implementation to avoid the dependency
* improved axis implementation: `update` is now a normal method
* introduced use_default tag type to set defaults
* whitespace fixes and doc update
2019-02-17 13:37:50 +01:00

41 lines
1.3 KiB
C++

// Copyright 2018 Hans Dembinski
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram.hpp>
#include <boost/histogram/serialization.hpp>
#include <cmath>
#include "utility_histogram.hpp"
#include "utility_serialization.hpp"
using namespace boost::histogram;
template <typename Tag>
void run_tests(const char* filename) {
// histogram_serialization
namespace tr = axis::transform;
auto a =
make(Tag(), axis::regular<>(3, -1, 1, "reg"), axis::circular<>(2, 0.0, 1.0, "cir"),
axis::regular<double, tr::log>(3, 1, std::exp(2), "reg-log"),
axis::regular<double, tr::pow, std::vector<int>, axis::option::overflow>(
tr::pow(0.5), 3, 1, 100, {1, 2, 3}),
axis::variable<>({1.0, 2.0, 3.0}, "var"), axis::category<>{3, 1, 2},
axis::integer<int, axis::null_type>(0, 2));
a(0.5, 0.2, 20, 20, 2.5, 1, 1);
print_xml(filename, a);
auto b = decltype(a)();
BOOST_TEST_NE(a, b);
load_xml(filename, b);
BOOST_TEST_EQ(a, b);
}
int main() {
run_tests<static_tag>(XML_PATH "histogram_serialization_test_static.xml");
run_tests<dynamic_tag>(XML_PATH "histogram_serialization_test_dynamic.xml");
return boost::report_errors();
}