From 439bbf923623da743e495e9394c5ef1ee1030d17 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 6 Nov 2026 17:54:40 +0100 Subject: [PATCH] Fix implicit char conversion in iterator-pair test The test built std::vector and from a char range, which -fsanitize=integer reports as an implicit conversion. Signed-off-by: Niels Lohmann --- tests/src/unit-deserialization.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp index a7e98747e..ec94678c0 100644 --- a/tests/src/unit-deserialization.cpp +++ b/tests/src/unit-deserialization.cpp @@ -1428,6 +1428,18 @@ std::string outcome_of(Iterator first, Iterator last) } } +/// the bytes of @a text as a vector of @a T (explicit casts: no implicit char conversion) +template +std::vector bytes_as(const std::string& text) +{ + std::vector result; + for (const char c : text) + { + result.push_back(static_cast(c)); + } + return result; +} + /// a std::string, std::vector, and as /// iterator pairs: the same as the byte path (std::list iterators) void check_iterator_pairs(const std::string& text) @@ -1444,10 +1456,10 @@ void check_iterator_pairs(const std::string& text) const std::vector vc(text.begin(), text.end()); CHECK(outcome_of(vc.begin(), vc.end()) == expected); - const std::vector vu(text.begin(), text.end()); + const std::vector vu = bytes_as(text); CHECK(outcome_of(vu.begin(), vu.end()) == expected); CHECK(json::accept(vu.begin(), vu.end()) == expected_accept); - const std::vector vs(text.begin(), text.end()); + const std::vector vs = bytes_as(text); CHECK(outcome_of(vs.begin(), vs.end()) == expected); } } // namespace