From 252bb1e67122bf10fb5ffbd437821dbbdb15d5c5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 10 Jul 2026 07:22:45 +0200 Subject: [PATCH] Avoid C-style array in test to satisfy clang-tidy avoid-c-arrays clang-tidy's cppcoreguidelines/hicpp/modernize-avoid-c-arrays checks flagged the char raw_data[] declaration used to reproduce the lvalue-only non-const ADL begin/end scenario. Use std::string instead and take a mutable pointer via &raw_data[0], which is the standard way to get a non-const char* into a string's buffer under C++11 (std::string::data() only returns non-const in C++17 and later). Signed-off-by: Niels Lohmann --- tests/src/unit-user_defined_input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/unit-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp index 91539476d..1a9b6394b 100644 --- a/tests/src/unit-user_defined_input.cpp +++ b/tests/src/unit-user_defined_input.cpp @@ -73,8 +73,8 @@ char* end(MyContainerNonConstADL& c) TEST_CASE("Custom container non-member non-const begin/end") { // Container with lvalue-only non-const ADL begin/end (bug reproduction) - char raw_data[] = "[1,2,3,4]"; - MyContainerNonConstADL data{raw_data, sizeof(raw_data) - 1}; + std::string raw_data = "[1,2,3,4]"; + MyContainerNonConstADL data{&raw_data[0], raw_data.size()}; // NOLINT(readability-container-data-pointer) const json as_json = json::parse(data); CHECK(as_json.at(0) == 1); CHECK(as_json.at(1) == 2);