// 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 #include #include #include #include #include #include #include #include "throw_exception.hpp" #include "utility_serialization.hpp" using unlimited_storage_type = boost::histogram::unlimited_storage<>; using namespace boost::histogram; template unlimited_storage_type prepare(std::size_t n, const T x) { std::unique_ptr v(new T[n]); std::fill(v.get(), v.get() + n, static_cast(0)); v.get()[0] = x; return unlimited_storage_type(n, v.get()); } template unlimited_storage_type prepare(std::size_t n) { return unlimited_storage_type(n, static_cast(nullptr)); } template void run_test(const std::string& filename) { const auto a = prepare(1, T(1)); print_xml(filename, a); unlimited_storage_type b; BOOST_TEST(!(a == b)); load_xml(filename, b); BOOST_TEST(a == b); } int main(int argc, char** argv) { BOOST_ASSERT(argc == 2); run_test(join(argv[1], "unlimited_storage_serialization_test_u8.xml")); run_test(join(argv[1], "unlimited_storage_serialization_test_u16.xml")); run_test(join(argv[1], "unlimited_storage_serialization_test_u32.xml")); run_test(join(argv[1], "unlimited_storage_serialization_test_u64.xml")); run_test( join(argv[1], "unlimited_storage_serialization_test_large_int.xml")); run_test(join(argv[1], "unlimited_storage_serialization_test_double.xml")); return boost::report_errors(); }