From 7b77e4cef8747f84104ba50584f590523b0595a6 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 14 Oct 2026 22:53:22 +0200 Subject: [PATCH] test: test vehicle definitions load with GCC and Clang All the tests reading a definition failed on Linux with "unknown vehicle definition section 0": the parsed definition was brace-initialised (auto const json{parse(...)}), which GCC and Clang take for the initializer list constructor of nlohmann::json, making an array holding the definition, while MSVC copies it. Initialise it with =, and require the definition to be a JSON object. Co-Authored-By: Claude Opus 5.5 --- tests/unit/vehicle.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index 721fab58..5c0d6d18 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -73,7 +73,11 @@ definition definition::load(std::string const &Name) { throw std::runtime_error("no test vehicle definition " + path); } definition result; - auto const json{nlohmann::ordered_json::parse(file, nullptr, true, true)}; + // not brace-initialised: json{other} makes an array of other with GCC and Clang (the initializer list constructor wins) + auto const json = nlohmann::ordered_json::parse(file, nullptr, true, true); + if (false == json.is_object()) { + throw std::runtime_error("test vehicle definition " + path + " isn't a JSON object"); + } for (auto const &[section, keys] : json.items()) { // keys starting with _ are comments if (section.starts_with('_')) {