MCPcopy Create free account
hub / github.com/boostorg/json / test

Method test

test/static_resource.cpp:46–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 void
47 test()
48 {
49 // static_resource(unsigned char*, size_t)
50 {
51 unsigned char buf[1000];
52 static_resource mr(
53 &buf[0], sizeof(buf));
54 BOOST_TEST(serialize(parse(
55 "[1,2,3]", &mr)) == "[1,2,3]");
56 }
57
58 #if defined(__cpp_lib_byte)
59 // static_resource(std::byte*, size_t)
60 {
61 std::byte buf[1000];
62 static_resource mr(
63 &buf[0], sizeof(buf));
64 BOOST_TEST(serialize(parse(
65 "[1,2,3]", &mr)) == "[1,2,3]");
66 }
67 #endif
68
69 // static_resource(unsigned char[N])
70 {
71 unsigned char buf[10];
72 static_resource mr(buf);
73 BOOST_TEST_THROWS(
74 serialize(parse("[1,2,3]", &mr)),
75 std::bad_alloc);
76 }
77
78 #if defined(__cpp_lib_byte)
79 // static_resource(std::byte[N])
80 {
81 std::byte buf[10];
82 static_resource mr(buf);
83 BOOST_TEST_THROWS(
84 serialize(parse("[1,2,3]", &mr)),
85 std::bad_alloc);
86 }
87 #endif
88
89 // static_resource(unsigned char[N], size_t)
90 {
91 unsigned char buf[1000];
92 static_resource mr(
93 buf, 500);
94 BOOST_TEST(serialize(parse(
95 "[1,2,3]", &mr)) == "[1,2,3]");
96 }
97
98 #if defined(__cpp_lib_byte)
99 // static_resource(std::byte[N])
100 {
101 std::byte buf[1000];
102 static_resource mr(
103 buf, 500);

Callers

nothing calls this directly

Calls 2

serializeFunction · 0.85
releaseMethod · 0.45

Tested by

no test coverage detected