Fix the BON8 CI failures of the bulk-read tests

- skip the contiguous-versus-stream tests of BON8 strings and BSON keys
  when exceptions are disabled: they catch the parse errors of invalid
  input, and without exceptions the library aborts instead
- use static_cast for the int64 test value (google-readability-casting)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-09-26 07:46:59 +02:00
1 parent a1381a619f
commit f7a41a2ee6
2 files changed
+7 -1

No files matched your search

+4 -1
View File
@@ -222,7 +222,7 @@ TEST_CASE("BON8")
SECTION("signed values are read back as unsigned when not negative")
{
const json j = json::from_bon8(json::to_bon8(json(std::int64_t(1000))));
const json j = json::from_bon8(json::to_bon8(json(static_cast<std::int64_t>(1000))));
CHECK(j.is_number_unsigned());
CHECK(j == 1000);
}
@@ -645,6 +645,8 @@ TEST_CASE("BON8")
}
}
// the test catches the exceptions of invalid input
#if !defined(JSON_NOEXCEPTION)
TEST_CASE("BON8 strings from contiguous and stream input")
{
// contiguous input copies the valid UTF-8 of a string in bulk, a stream
@@ -700,6 +702,7 @@ TEST_CASE("BON8 strings from contiguous and stream input")
CHECK_THROWS_WITH_AS(_ = json::from_bon8(inputs[7]), "[json.exception.parse_error.110] parse error at byte 23: syntax error while parsing BON8 string: unexpected end of input", json::parse_error&);
CHECK_THROWS_WITH_AS(_ = json::from_bon8(inputs[9]), "[json.exception.parse_error.110] parse error at byte 22: syntax error while parsing BON8 value: expected end of input; last byte: 0x91", json::parse_error&);
}
#endif
// use this testcase outside [hide] to run it with Valgrind
TEST_CASE("BON8 nesting does not consume the call stack")