]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/histogram/test/unlimited_storage_serialization_test.cpp
1 // Copyright 2018 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 #include <boost/archive/text_iarchive.hpp>
8 #include <boost/archive/text_oarchive.hpp>
9 #include <boost/assert.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/histogram/serialization.hpp>
12 #include <boost/histogram/unlimited_storage.hpp>
15 #include "throw_exception.hpp"
16 #include "utility_serialization.hpp"
18 using unlimited_storage_type
= boost::histogram::unlimited_storage
<>;
20 using namespace boost::histogram
;
23 unlimited_storage_type
prepare(std::size_t n
, const T x
) {
24 std::unique_ptr
<T
[]> v(new T
[n
]);
25 std::fill(v
.get(), v
.get() + n
, static_cast<T
>(0));
27 return unlimited_storage_type(n
, v
.get());
31 unlimited_storage_type
prepare(std::size_t n
) {
32 return unlimited_storage_type(n
, static_cast<T
*>(nullptr));
36 void run_test(const std::string
& filename
) {
37 const auto a
= prepare(1, T(1));
38 print_xml(filename
, a
);
39 unlimited_storage_type b
;
40 BOOST_TEST(!(a
== b
));
41 load_xml(filename
, b
);
45 int main(int argc
, char** argv
) {
46 BOOST_ASSERT(argc
== 2);
48 run_test
<uint8_t>(join(argv
[1], "unlimited_storage_serialization_test_u8.xml"));
49 run_test
<uint16_t>(join(argv
[1], "unlimited_storage_serialization_test_u16.xml"));
50 run_test
<uint32_t>(join(argv
[1], "unlimited_storage_serialization_test_u32.xml"));
51 run_test
<uint64_t>(join(argv
[1], "unlimited_storage_serialization_test_u64.xml"));
52 run_test
<unlimited_storage_type::large_int
>(
53 join(argv
[1], "unlimited_storage_serialization_test_large_int.xml"));
54 run_test
<double>(join(argv
[1], "unlimited_storage_serialization_test_double.xml"));
56 return boost::report_errors();