From d7ea86d22571bda13aa57a9c84058c971dfccd15 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 27 Sep 2026 08:06:15 +0200 Subject: [PATCH] Convert the bytes of the BON8 test strings explicitly The str() helper constructed a std::string from a byte range, which converts each unsigned char implicitly; -fsanitize=integer reports that for bytes of 0x80 and above (ci_test_clang_sanitizer). Signed-off-by: Niels Lohmann --- tests/src/unit-bon8.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-bon8.cpp b/tests/src/unit-bon8.cpp index 3866180ba..030e1d5c3 100644 --- a/tests/src/unit-bon8.cpp +++ b/tests/src/unit-bon8.cpp @@ -105,7 +105,15 @@ using bytes = std::vector; /// @return the string with the given bytes std::string str(const bytes& b) { - return {b.begin(), b.end()}; + // converted one by one: constructing the string from the byte range + // converts implicitly, which -fsanitize=integer reports for bytes >= 0x80 + std::string result; + result.reserve(b.size()); + for (const auto c : b) + { + result.push_back(static_cast(c)); + } + return result; } /// check that @a j is serialized to @a expected and that @a expected is read back as @a j