From 90987b2a63f493632e5d3a0065b53211fa09ded7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 23 Nov 2026 08:21:01 +0100 Subject: [PATCH] Fix the AppVeyor build of develop with VS 2015 and VS 2017 (#6154) Signed-off-by: Niels Lohmann --- tests/src/unit-bon8.cpp | 2 +- tests/src/unit-class_parser.cpp | 10 +++++++--- tests/src/unit-ubjson_valueless.cpp | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/src/unit-bon8.cpp b/tests/src/unit-bon8.cpp index 84522db64..f05edd4f8 100644 --- a/tests/src/unit-bon8.cpp +++ b/tests/src/unit-bon8.cpp @@ -622,7 +622,7 @@ TEST_CASE("BON8") // with a terminated string, strict = false leaves the next value in the stream std::istringstream terminated(std::string("\x61\xFF\x90", 3)); CHECK(json::from_bon8(terminated, false) == "a"); - CHECK((terminated.tellg() == 2)); + CHECK(static_cast(terminated.tellg()) == 2); CHECK(json::from_bon8(terminated, false) == 0); // without the terminator, the next value would be lost diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index c1a86ca5f..c64a380cf 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -41,6 +41,7 @@ using nlohmann::json; #include #include #include +#include #include #include #include @@ -2875,13 +2876,16 @@ TEST_CASE("diagnostic positions: value lifetime, input adapters, and SAX") SECTION("std::ifstream: positions are consistent, not npos") { const std::string s = R"({"a":1,"b":2})"; + // the C++11 and C++20 builds of this test run in parallel in the same directory + std::random_device rd; + const std::string temp_name = "unit-class_parser_diagnostic_positions-" + std::to_string(rd()) + ".tmp"; { - std::ofstream file("unit-class_parser_diagnostic_positions.tmp"); + std::ofstream file(temp_name); file << s; } { - std::ifstream f("unit-class_parser_diagnostic_positions.tmp"); + std::ifstream f(temp_name); const json j = json::parse(f); CHECK(j.start_pos() == 0); @@ -2889,7 +2893,7 @@ TEST_CASE("diagnostic positions: value lifetime, input adapters, and SAX") CHECK(j["a"].start_pos() == 5); } - static_cast(std::remove("unit-class_parser_diagnostic_positions.tmp")); + static_cast(std::remove(temp_name.c_str())); } SECTION("iterator-pair input: positions are consistent, not npos") diff --git a/tests/src/unit-ubjson_valueless.cpp b/tests/src/unit-ubjson_valueless.cpp index 2ceb3f99b..91bfe9e69 100644 --- a/tests/src/unit-ubjson_valueless.cpp +++ b/tests/src/unit-ubjson_valueless.cpp @@ -238,8 +238,8 @@ TEST_CASE("UBJSON the valueless elements of a whole input are bounded") std::vector input = {'['}; utils::append_valueless_array(input, 'Z', first_count); input.insert(input.end(), {'[', '$', 'U', '#', 'l', - static_cast(payload >> 24), static_cast(payload >> 16), - static_cast(payload >> 8), static_cast(payload) + static_cast((payload >> 24) & 0xFFu), static_cast((payload >> 16) & 0xFFu), + static_cast((payload >> 8) & 0xFFu), static_cast(payload & 0xFFu) }); input.insert(input.end(), payload, 0x01); utils::append_valueless_array(input, 'Z', count);