From 5232f777dfe838bc9e6c2381e1790628976a912c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 19 Aug 2026 22:44:54 +0200 Subject: [PATCH] Do not discard the parse result in the error position check json::parse is declared warn_unused_result, and CHECK_THROWS_WITH_AS evaluates its expression as a discarded statement, so the assertion broke the -Werror builds (GCC -Werror=unused-result, MSVC C4834 under /WX). Compare against the helper that already captures the message instead. Signed-off-by: Niels Lohmann --- tests/src/unit-class_lexer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/src/unit-class_lexer.cpp b/tests/src/unit-class_lexer.cpp index 0dd456b8c..57ec96f20 100644 --- a/tests/src/unit-class_lexer.cpp +++ b/tests/src/unit-class_lexer.cpp @@ -350,9 +350,8 @@ TEST_CASE("lexer number fast path") // the column must be the one the offending token actually starts at, // not the 0 that an unget() across the newline used to leave behind - CHECK_THROWS_WITH_AS(json::parse("[01\n]"), - "[json.exception.parse_error.101] parse error at line 1, column 3: " - "syntax error while parsing array - unexpected number literal; expected ']'", - json::parse_error&); + CHECK(contiguous_error("[01\n]") == + "[json.exception.parse_error.101] parse error at line 1, column 3: " + "syntax error while parsing array - unexpected number literal; expected ']'"); } }