Build the tests with C++17/C++20-only sections in those standards
cmake/test.cmake only adds the _cpp17/_cpp20 variants of a unit test if the file mentions JSON_HAS_CPP_17/JSON_HAS_CPP_20. Several files have sections that need C++17 or C++20 (std::filesystem::path, std::string_view, char8_t, std::u8string, operator<=>, ranges) but never mention the macros, so by default these sections were only compiled away in the C++11 build and only ran in the CI jobs that force a standard. Mention the macros next to the guarded sections, as the other tests do: unit-to_json-rvalue.cpp (C++17 and C++20), unit-json_view_builder.cpp (C++17), unit-class_parser.cpp, unit-recursion_depth_limit.cpp, unit-ubjson_valueless.cpp, unit-custom-number-types.cpp and unit-allocator.cpp (C++20). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
8 files changed
+61
-5
No files matched your search
@@ -6,6 +6,13 @@
|
||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||
// When using macros that are only defined for particular versions of the standard
|
||||
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||
// version macro in a comment close by, like this:
|
||||
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||
|
||||
#include "doctest_compatibility.h"
|
||||
|
||||
#define JSON_TESTS_PRIVATE
|
||||
@@ -15,6 +22,7 @@ using nlohmann::json;
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <valarray>
|
||||
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||
#if JSON_HAS_RANGES
|
||||
#include <ranges>
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user