MCPcopy Create free account
hub / github.com/Icinga/icinga2 / TestJsonStackSize

Function TestJsonStackSize

test/base-json.cpp:298–314  ·  view source on GitHub ↗

This test case decodes JSON nested much deeper (see safetyFactor) than the default depth limit and performs some * operations on the resulting values. This is done with its limited stack size on order to verify that the default * limit is low enough to be safe. Note that this isn't an exact science unfortunately: other recursive operations may * have larger stack frames and these operations are

Source from the content-addressed store, hash-verified

296 * the Boost version), once in a pthread thread (which may not be available everywhere).
297 */
298static void TestJsonStackSize()
299{
300 constexpr size_t safetyFactor = 10;
301 constexpr size_t depth = JsonDecodeDefaultDepthLimit * safetyFactor;
302
303 Value val;
304
305 BOOST_REQUIRE_NO_THROW(val = JsonDecode(MakeNestedJsonArray(depth), depth));
306 BOOST_REQUIRE_NO_THROW(val.Clone());
307 BOOST_REQUIRE_NO_THROW(Convert::ToString(val));
308 BOOST_REQUIRE_NO_THROW(JsonDecode(JsonEncode(val), depth));
309
310 BOOST_REQUIRE_NO_THROW(val = JsonDecode(MakeNestedJsonObject(depth), depth));
311 BOOST_REQUIRE_NO_THROW(val.Clone());
312 BOOST_REQUIRE_NO_THROW(Convert::ToString(val));
313 BOOST_REQUIRE_NO_THROW(JsonDecode(JsonEncode(val), depth));
314}
315
316BOOST_AUTO_TEST_CASE(stack_size_coroutine)
317{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 3

MakeNestedJsonArrayFunction · 0.85
MakeNestedJsonObjectFunction · 0.85
CloneMethod · 0.45

Tested by

no test coverage detected