diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp index 85e3e2a8e..f310a70d1 100644 --- a/tests/src/unit-comparison.cpp +++ b/tests/src/unit-comparison.cpp @@ -27,16 +27,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// cmake/test.cmake selects the C++ standard versions with which to build a +// unit test based on the presence of JSON_HAS_CPP_ 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_ (do not remove; see note at top of file) + #include "doctest_compatibility.h" #define JSON_TESTS_PRIVATE #include using nlohmann::json; - -// build this testcase in C++20-mode (CMake code detects macro use) -// JSON_HAS_CPP_20 - #if JSON_HAS_THREE_WAY_COMPARISON // this can be replaced with the doctest stl extension header in version 2.5 namespace doctest @@ -144,6 +147,7 @@ TEST_CASE("lexicographical comparison operators") CAPTURE(j) // check precomputed values #if JSON_HAS_THREE_WAY_COMPARISON + // JSON_HAS_CPP_20 (do not remove; see note at top of file) CHECK((j_types[i] < j_types[j]) == expected_lt[i][j]); #else CHECK(operator<(j_types[i], j_types[j]) == expected_lt[i][j]); @@ -153,6 +157,7 @@ TEST_CASE("lexicographical comparison operators") } } #if JSON_HAS_THREE_WAY_COMPARISON + // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("comparison: 3-way") { std::vector> expected = @@ -508,6 +513,7 @@ TEST_CASE("lexicographical comparison operators") } #if JSON_HAS_THREE_WAY_COMPARISON + // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("comparison: 3-way") { std::vector> expected = diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index c61b249c2..bfa9bb98f 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -27,6 +27,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// cmake/test.cmake selects the C++ standard versions with which to build a +// unit test based on the presence of JSON_HAS_CPP_ 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_ (do not remove; see note at top of file) + #include "doctest_compatibility.h" #define JSON_TESTS_PRIVATE @@ -1582,12 +1589,4 @@ TEST_CASE("JSON to enum mapping") } } -#ifdef JSON_HAS_CPP_17 - #undef JSON_HAS_CPP_17 -#endif - -#ifdef JSON_HAS_CPP_14 - #undef JSON_HAS_CPP_14 -#endif - DOCTEST_CLANG_SUPPRESS_WARNING_POP diff --git a/tests/src/unit-items.cpp b/tests/src/unit-items.cpp index b219bc27e..64d92b59e 100644 --- a/tests/src/unit-items.cpp +++ b/tests/src/unit-items.cpp @@ -1448,13 +1448,5 @@ TEST_CASE("items()") } } -#ifdef JSON_HAS_CPP_17 - #undef JSON_HAS_CPP_17 -#endif - -#ifdef JSON_HAS_CPP_14 - #undef JSON_HAS_CPP_14 -#endif - DOCTEST_GCC_SUPPRESS_WARNING_POP DOCTEST_CLANG_SUPPRESS_WARNING_POP diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp index 36b28cc18..b9c418c16 100644 --- a/tests/src/unit-iterators2.cpp +++ b/tests/src/unit-iterators2.cpp @@ -27,13 +27,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// cmake/test.cmake selects the C++ standard versions with which to build a +// unit test based on the presence of JSON_HAS_CPP_ 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_ (do not remove; see note at top of file) + #include "doctest_compatibility.h" #include using nlohmann::json; #if JSON_HAS_RANGES - // JSON_HAS_CPP_20 (magic keyword; do not remove) #include #include #endif @@ -890,6 +896,7 @@ TEST_CASE("iterators 2") #if JSON_HAS_RANGES + // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("ranges") { SECTION("concepts") diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 04cbac679..3ee234eee 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -27,6 +27,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// cmake/test.cmake selects the C++ standard versions with which to build a +// unit test based on the presence of JSON_HAS_CPP_ 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_ (do not remove; see note at top of file) + #include "doctest_compatibility.h" // for some reason including this after the json header leads to linker errors with VS 2017... @@ -48,7 +55,6 @@ using ordered_json = nlohmann::ordered_json; #endif #if JSON_HAS_EXPERIMENTAL_FILESYSTEM -// JSON_HAS_CPP_17 (magic keyword; do not remove) #include namespace nlohmann::detail { @@ -788,6 +794,7 @@ TEST_CASE("regression tests 2") } #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM + // JSON_HAS_CPP_17 (do not remove; see note at top of file) SECTION("issue #3070 - Version 3.10.3 breaks backward-compatibility with 3.10.2 ") { nlohmann::detail::std_fs::path text_path("/tmp/text.txt");