From 338442f4a01a25f08ec631b87ff57c7f337251fd Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 May 2026 21:56:32 +0200 Subject: [PATCH] :bug: use correct indentation character on resize Signed-off-by: Niels Lohmann --- tests/src/unit-inspection.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/src/unit-inspection.cpp b/tests/src/unit-inspection.cpp index c70913d5b..9d6d06e23 100644 --- a/tests/src/unit-inspection.cpp +++ b/tests/src/unit-inspection.cpp @@ -245,6 +245,35 @@ TEST_CASE("object inspection") CHECK(binary.dump(1024).size() == 2086); } + SECTION("indentation and resize") + { + SECTION("array") + { + const auto j_array = "[[[[[[]]]]]]"_json; + // check right size after indentation triggering a resize + CHECK(j_array.dump(1024).size() == 25622); + // check if right indentation symbol is used + CHECK(j_array.dump(1024, '\t')[4096] == '\t'); + } + + SECTION("object") + { + const auto j_object = R"({"":{"":{"":{"":{"":{}}}}}})"_json; + // check right size after indentation triggering a resize + CHECK(j_object.dump(1024).size() == 25642); + // check if right indentation symbol is used + CHECK(j_object.dump(1024, '\t')[4096] == '\t'); + } + + SECTION("binary") + { + const auto j_binary = json::binary({1, 2, 3}, 128); + // check right size after indentation triggering a resize + CHECK(j_binary.dump(1024).size() == 2086); + CHECK(j_binary.dump(1024, '\t')[1024] == '\t'); + } + } + SECTION("dump and floating-point numbers") { auto s = json(42.23).dump();