test: drop a trailing NUL byte from the nativejson-benchmark 1e308 fixture

The "doubles" compliance test built its 1e308 literal as a std::string
sized to 312 bytes with an explicit trailing '\0' at index 311, relying
on the old NUL-as-EOF lexer behavior removed earlier in this branch: with
that removed, the NUL is ordinary (invalid) trailing data instead of
being silently swallowed, so json::parse() correctly rejected it with
parse_error.101 - breaking CI across every compiler/platform, since this
one nativejson-benchmark TEST_CASE is exercised by every test job.

No padding is needed at all: json::parse(const std::string&) already
uses the string's own size(), not a NUL terminator. Drop the trailing
byte and shrink the string by one to match (index 310 - the new last
index - is where ']' now goes), fixing this the same way the other
pre-existing tests in this branch that depended on the same bug were
already fixed.

Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4RQ1Ahan5YAGbnAQGjZTY
This commit is contained in:
Niels Lohmann
2026-09-15 10:22:47 +00:00
co-authored by Claude Sonnet 5
parent 633eef8494
commit 55ff4c9eff
+4 -2
View File
@@ -214,11 +214,13 @@ TEST_CASE("compliance tests from nativejson-benchmark")
5708990770823839524233143877797980545530986496.0); 5708990770823839524233143877797980545530986496.0);
{ {
std::string n1e308(312, '0'); // '1' followed by 308 '0' // note: no trailing NUL byte - a NUL is ordinary (invalid) data
// now, not end-of-input, so it is no longer needed (or valid)
// padding here; see issue #5530
std::string n1e308(311, '0'); // '1' followed by 308 '0'
n1e308[0] = '['; n1e308[0] = '[';
n1e308[1] = '1'; n1e308[1] = '1';
n1e308[310] = ']'; n1e308[310] = ']';
n1e308[311] = '\0';
TEST_DOUBLE(n1e308, 1E308); TEST_DOUBLE(n1e308, 1E308);
} }