From 9d75c87de56f40bfa9b716263eb82fae7a3c6f48 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 21 Aug 2026 01:41:05 +0200 Subject: [PATCH] Check both shapes without a C-style array clang-tidy rejects the array the two shapes were iterated over (cppcoreguidelines-avoid-c-arrays). The array only existed because astyle reformats a range-for over a braced initializer list into something unreadable; naming the two cases avoids both. Signed-off-by: Niels Lohmann --- tests/src/unit-diagnostic-positions.cpp | 27 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/src/unit-diagnostic-positions.cpp b/tests/src/unit-diagnostic-positions.cpp index 7f1471d5e..a9a595245 100644 --- a/tests/src/unit-diagnostic-positions.cpp +++ b/tests/src/unit-diagnostic-positions.cpp @@ -112,15 +112,26 @@ TEST_CASE("Better diagnostics with positions") } }; - const bool shapes[] = {false, true}; - for (const bool objects : shapes) + const auto check_arrays = [&check_copy](std::size_t depth) { - check_copy(1, objects); - check_copy(127, objects); - check_copy(128, objects); - check_copy(129, objects); - check_copy(300, objects); - } + check_copy(depth, false); + }; + const auto check_objects = [&check_copy](std::size_t depth) + { + check_copy(depth, true); + }; + + check_arrays(1); + check_arrays(127); + check_arrays(128); + check_arrays(129); + check_arrays(300); + + check_objects(1); + check_objects(127); + check_objects(128); + check_objects(129); + check_objects(300); } SECTION("JSON patch add to primitive parent (#4292)")