From 74e027c30a22a813d6aea0762cdf02b00bc45ea2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 12 Nov 2026 16:15:18 +0100 Subject: [PATCH] Fix clang-tidy errors in the std::u8string tests Test the lvalue path with the const original instead of a mutable copy and the rvalue path with a temporary (misc-const-correctness), and mark the intentional char8_t array with NOLINT (avoid-c-arrays). Signed-off-by: Niels Lohmann --- tests/src/unit-conversions2.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/src/unit-conversions2.cpp b/tests/src/unit-conversions2.cpp index 8cb44a231..afba3e1e9 100644 --- a/tests/src/unit-conversions2.cpp +++ b/tests/src/unit-conversions2.cpp @@ -761,9 +761,8 @@ TEST_CASE("std::u8string") CHECK(json(with_nul).template get() == with_nul); // the lvalue and rvalue paths, and in containers - std::u8string lvalue = utf8; - CHECK(json(lvalue).template get() == utf8); - CHECK(json(std::move(lvalue)).template get() == utf8); + CHECK(json(utf8).template get() == utf8); + CHECK(json(std::u8string(utf8)).template get() == utf8); const std::vector vec = {utf8, u8"x"}; json const j_vec = vec; CHECK(j_vec.is_array()); @@ -812,7 +811,7 @@ TEST_CASE("std::u8string") CHECK(j_view.is_array()); CHECK(j_view.size() == 8); - const char8_t arr[] = u8"ab"; + const char8_t arr[] = u8"ab"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) json const j_arr = arr; CHECK(j_arr == json::array({0x61, 0x62, 0})); }