diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 4d89d901b..22cf09093 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -525,6 +525,7 @@ add_custom_target(ci_test_noglobaludls COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug -GNinja -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_GlobalUDLs=OFF + -DCMAKE_CXX_FLAGS=-DJSON_TEST_NO_GLOBAL_UDLS -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noglobaludls COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noglobaludls COMMAND cd ${PROJECT_BINARY_DIR}/build_noglobaludls && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index df821beb0..e5b7f5db8 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -11,7 +11,9 @@ #define JSON_TESTS_PRIVATE #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp index f4a76b303..d42a6997a 100644 --- a/tests/src/unit-deserialization.cpp +++ b/tests/src/unit-deserialization.cpp @@ -11,7 +11,9 @@ #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index ab59461eb..918c263d2 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -10,7 +10,9 @@ #include "doctest_compatibility.h" #include -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_json) { diff --git a/tests/src/unit-json_patch.cpp b/tests/src/unit-json_patch.cpp index 0b39d00ae..1f6716bde 100644 --- a/tests/src/unit-json_patch.cpp +++ b/tests/src/unit-json_patch.cpp @@ -10,7 +10,9 @@ #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include "make_test_data_available.hpp" diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp index 445b8f026..4f457d0ee 100644 --- a/tests/src/unit-json_pointer.cpp +++ b/tests/src/unit-json_pointer.cpp @@ -11,7 +11,9 @@ #define JSON_TESTS_PRIVATE #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include diff --git a/tests/src/unit-merge_patch.cpp b/tests/src/unit-merge_patch.cpp index 47bab58f7..af56b0dec 100644 --- a/tests/src/unit-merge_patch.cpp +++ b/tests/src/unit-merge_patch.cpp @@ -10,7 +10,9 @@ #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif TEST_CASE("JSON Merge Patch") { diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp index 5c720f6ac..f90190315 100644 --- a/tests/src/unit-msgpack.cpp +++ b/tests/src/unit-msgpack.cpp @@ -10,7 +10,9 @@ #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp index 71ffffff6..108cdd039 100644 --- a/tests/src/unit-readme.cpp +++ b/tests/src/unit-readme.cpp @@ -10,7 +10,9 @@ #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index 77a194db6..c7720b4f1 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -14,7 +14,9 @@ #define JSON_TESTS_PRIVATE #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 5ba3d310f..3f82301cc 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -22,7 +22,9 @@ #include using json = nlohmann::json; using ordered_json = nlohmann::ordered_json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include diff --git a/tests/src/unit-udl.cpp b/tests/src/unit-udl.cpp index 19d901f2b..526e05b27 100644 --- a/tests/src/unit-udl.cpp +++ b/tests/src/unit-udl.cpp @@ -8,8 +8,6 @@ #include "doctest_compatibility.h" -#undef JSON_USE_GLOBAL_UDLS -#define JSON_USE_GLOBAL_UDLS 0 #include TEST_CASE("user-defined string literals") @@ -48,4 +46,12 @@ TEST_CASE("user-defined string literals") CHECK(R"({"foo": "bar", "baz": 42})"_json == j_expected); CHECK("/foo/bar"_json_pointer == ptr_expected); } + +#ifndef JSON_TEST_NO_GLOBAL_UDLS + SECTION("global namespace") + { + CHECK(R"({"foo": "bar", "baz": 42})"_json == j_expected); + CHECK("/foo/bar"_json_pointer == ptr_expected); + } +#endif } diff --git a/tests/src/unit-udt.cpp b/tests/src/unit-udt.cpp index 7952442cf..2cecca3d9 100644 --- a/tests/src/unit-udt.cpp +++ b/tests/src/unit-udt.cpp @@ -14,7 +14,9 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") #include using nlohmann::json; -using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#ifdef JSON_TEST_NO_GLOBAL_UDLS + using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) +#endif #include #include