From be6aff968a3892e34e2be9b6d08a407395529775 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 19 Jul 2026 18:39:26 +0000 Subject: [PATCH] :white_check_mark: verify full indentation runs stay intact after resize Adapted from a regression test in PR #5273: checks that the whole contiguous run of indent characters at a given nesting level is present in the dump output, rather than only the total size or a single spot-checked character. Signed-off-by: Claude --- tests/src/unit-inspection.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/src/unit-inspection.cpp b/tests/src/unit-inspection.cpp index d79764bff..7be8f6c36 100644 --- a/tests/src/unit-inspection.cpp +++ b/tests/src/unit-inspection.cpp @@ -278,6 +278,36 @@ TEST_CASE("object inspection") // check resize is large enough CHECK(j_binary.dump(10000).size() == 20038); } + + SECTION("full-width run integrity") + { + // the size/single-index checks above can't catch a corrupted byte + // in the middle of an indentation run, so also verify each level's + // indentation is an intact, uninterrupted run of the indent character + const std::string::size_type width = 1100; + + SECTION("object") + { + const json j_object = {{"outer", {{"inner", 1}}}}; + const std::string s = j_object.dump(static_cast(width)); + CHECK(s.find('\n' + std::string(width, ' ') + "\"outer\"") != std::string::npos); + CHECK(s.find('\n' + std::string(2 * width, ' ') + "\"inner\"") != std::string::npos); + } + + SECTION("array") + { + const json j_array = json::array({json::array({1})}); + const std::string s = j_array.dump(static_cast(width)); + CHECK(s.find('\n' + std::string(2 * width, ' ') + '1') != std::string::npos); + } + + SECTION("binary") + { + const json j_binary = json::binary({1, 2, 3}); + const std::string s = j_binary.dump(static_cast(width)); + CHECK(s.find('\n' + std::string(width, ' ') + "\"bytes\"") != std::string::npos); + } + } } SECTION("dump and floating-point numbers")