]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/json/test/static_resource.cpp
2 // Copyright (c) 2020 Vinnie Falco (vinnie.falco@gmail.com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/json
10 // Test that header file is self-contained.
11 #include <boost/json/static_resource.hpp>
13 #include <boost/json/parse.hpp>
14 #include <boost/json/serialize.hpp>
17 #include "test_suite.hpp"
21 BOOST_STATIC_ASSERT( std::is_nothrow_destructible
<static_resource
>::value
);
23 class static_resource_test
29 //--------------------------------------
31 unsigned char buf
[ 4000 ];
32 static_resource
mr( buf
);
34 // Parse the string, using our memory resource
35 value jv
= parse( "[1,2,3]", &mr
);
40 //--------------------------------------
46 // static_resource(unsigned char*, size_t)
48 unsigned char buf
[1000];
50 &buf
[0], sizeof(buf
));
51 BOOST_TEST(serialize(parse(
52 "[1,2,3]", &mr
)) == "[1,2,3]");
55 #if defined(__cpp_lib_byte)
56 // static_resource(std::byte*, size_t)
60 &buf
[0], sizeof(buf
));
61 BOOST_TEST(serialize(parse(
62 "[1,2,3]", &mr
)) == "[1,2,3]");
66 // static_resource(unsigned char[N])
68 unsigned char buf
[10];
69 static_resource
mr(buf
);
71 serialize(parse("[1,2,3]", &mr
)),
75 #if defined(__cpp_lib_byte)
76 // static_resource(std::byte[N])
79 static_resource
mr(buf
);
81 serialize(parse("[1,2,3]", &mr
)),
86 // static_resource(unsigned char[N], size_t)
88 unsigned char buf
[1000];
91 BOOST_TEST(serialize(parse(
92 "[1,2,3]", &mr
)) == "[1,2,3]");
95 #if defined(__cpp_lib_byte)
96 // static_resource(std::byte[N])
101 BOOST_TEST(serialize(parse(
102 "[1,2,3]", &mr
)) == "[1,2,3]");
108 unsigned char buf
[10];
111 (void)mr
.allocate(10,1);
116 (void)mr
.allocate(10,1);
127 TEST_SUITE(static_resource_test
, "boost.json.static_resource");