Mark the code of json_view that tests cannot reach

The 4 GiB limit and the fallback for an input that parse() accepts but
the view rejects (a bug) are excluded from the coverage; shrink_to_fit()
of an empty document is tested.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 02:33:58 +02:00
parent aa1a0c7561
commit 207fc01576
4 changed files with 19 additions and 7 deletions

View File

@@ -351,6 +351,11 @@ TEST_CASE("json_view")
CHECK(reused.memory_usage() < grown);
CHECK(reused.root().materialize() == json::parse(smaller));
// an empty document has nothing to release
json_document empty;
empty.shrink_to_fit();
CHECK(empty.memory_usage() == 0);
// a small document stays in the storage block of the header
json_document small = json_document::parse("[1,[2,3],{\"a\":\"b\\n\"}]"); // NOLINT(modernize-raw-string-literal)
small.shrink_to_fit();