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 723cf14be4
commit 06bebe2af6
4 changed files with 15 additions and 2 deletions

View File

@@ -382,6 +382,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();