mirror of
https://github.com/nlohmann/json.git
synced 2026-04-08 00:58:55 +00:00
Fix global UDLs (#3646)
* Add ci_test_noglobaludls to CI * Really default JSON_GLOBAL_UDLS to 1 * Test global UDLs * Suppress warnings * Clarify documentation
This commit is contained in:
committed by
GitHub
parent
817a4a2117
commit
cbaf1033be
@@ -11,7 +11,9 @@
|
||||
#define JSON_TESTS_PRIVATE
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <valarray>
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <iostream>
|
||||
#include <iterator>
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#include "doctest_compatibility.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <fstream>
|
||||
#include "make_test_data_available.hpp"
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
#define JSON_TESTS_PRIVATE
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <sstream>
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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")
|
||||
{
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <fstream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <deque>
|
||||
#include <forward_list>
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
#define JSON_TESTS_PRIVATE
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <fstream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <cstdio>
|
||||
#include <list>
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include "doctest_compatibility.h"
|
||||
|
||||
#undef JSON_USE_GLOBAL_UDLS
|
||||
#define JSON_USE_GLOBAL_UDLS 0
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept")
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
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 <map>
|
||||
#include <memory>
|
||||
|
||||
Reference in New Issue
Block a user