]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/pfr/test/run/read_write.cpp
1 // Copyright (c) 2016-2020 Antony Polukhin
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/pfr/io.hpp>
11 #include <boost/core/lightweight_test.hpp>
14 void test_write_read(const T
& value
) {
17 ss
<< boost::pfr::io(value
);
18 ss
>> boost::pfr::io(result
);
19 BOOST_TEST_EQ(value
.f0
, result
.f0
);
20 BOOST_TEST_EQ(value
.f1
, result
.f1
);
21 BOOST_TEST_EQ(value
.f2
, result
.f2
);
22 BOOST_TEST_EQ(value
.f3
, result
.f3
);
23 BOOST_TEST_EQ(value
.f4
, result
.f4
);
27 void to_string_test(const T
& value
, const char* ethalon
) {
29 ss
<< boost::pfr::io(value
);
30 BOOST_TEST_EQ(ss
.str(), ethalon
);
34 void test_type(const T
& value
, const char* ethalon
) {
35 test_write_read(value
);
36 to_string_test(value
, ethalon
);
41 struct with_operator
{};
42 inline bool operator==(with_operator
, with_operator
) {
45 std::ostream
& operator<<(std::ostream
& os
, with_operator
) {
46 return os
<< "{with_operator}";
48 std::istream
& operator>>(std::istream
& is
, with_operator
&) {
62 test_type(test1
{1, 2, '3', 4, 5}, "{1, 2, 3, 4, 5}");
63 test_type(test1
{199, 299, '9', 499, 599}, "{199, 299, 9, 499, 599}");
72 test_type(test2
{}, "{{with_operator}, {with_operator}, {with_operator}, {with_operator}, {with_operator}}");
83 test3
{1, 2, '3', 4, {}},
84 "{1, 2, 3, 4, {with_operator}}"
87 return boost::report_errors();