mirror of
https://github.com/nlohmann/json.git
synced 2026-11-14 19:38:20 +00:00
Fix develop CI: GCC 4.8, Clang 3.4 and clang-tidy errors (#6100)
* Fix develop CI: GCC 4.8, Clang 3.4 and clang-tidy errors - unit-json_patch.cpp: move multi-line raw strings out of CHECK(), which GCC 4.8 cannot parse inside a macro argument - unit-recursion_depth_limit.cpp: value-initialize the const std::hash (Clang 3.4 rejects default initialization of a const object) - json_view: silence modernize-use-transparent-functors (std::less<> is C++14), bugprone-suspicious-stringview-data-usage (the length comes from the node) and the deliberate use-after-clear() / owning-memory hits in unit-json_view_builder.cpp; use a raw string literal there Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix clang-tidy errors in the std::u8string tests Test the lvalue path with the const original instead of a mutable copy and the rvalue path with a temporary (misc-const-correctness), and mark the intentional char8_t array with NOLINT (avoid-c-arrays). Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
cdfb130fa6
commit
2755952d36
7 files changed
+25
-16
No files matched your search
@@ -2682,25 +2682,27 @@ TEST_CASE("JSON patch - consecutive operations with paths that share a prefix")
|
||||
const json doc = json::parse(R"({"a": [{"b": [1, 2, 3]}, {"b": [4, 5, 6]}], "c": {"d": {"e": 7}}})");
|
||||
|
||||
// an element inserted before the elements of an array moves them
|
||||
CHECK(doc.patch(json::parse(R"([
|
||||
const json inserted = json::parse(R"([
|
||||
{"op": "test", "path": "/a/0/b/2", "value": 3},
|
||||
{"op": "add", "path": "/a/0", "value": {"b": [9]}},
|
||||
{"op": "test", "path": "/a/1/b/2", "value": 3},
|
||||
{"op": "test", "path": "/a/0/b/0", "value": 9},
|
||||
{"op": "test", "path": "/a/2/b/0", "value": 4}
|
||||
])")) == json::parse(R"({"a": [{"b": [9]}, {"b": [1, 2, 3]}, {"b": [4, 5, 6]}], "c": {"d": {"e": 7}}})"));
|
||||
])");
|
||||
CHECK(doc.patch(inserted) == json::parse(R"({"a": [{"b": [9]}, {"b": [1, 2, 3]}, {"b": [4, 5, 6]}], "c": {"d": {"e": 7}}})"));
|
||||
|
||||
// an element removed from the front
|
||||
CHECK(doc.patch(json::parse(R"([
|
||||
const json removed_front = json::parse(R"([
|
||||
{"op": "test", "path": "/a/1/b/2", "value": 6},
|
||||
{"op": "remove", "path": "/a/0"},
|
||||
{"op": "test", "path": "/a/0/b/2", "value": 6},
|
||||
{"op": "replace", "path": "/a/0/b/2", "value": 60},
|
||||
{"op": "test", "path": "/a/0/b/2", "value": 60}
|
||||
])")) == json::parse(R"({"a": [{"b": [4, 5, 60]}], "c": {"d": {"e": 7}}})"));
|
||||
])");
|
||||
CHECK(doc.patch(removed_front) == json::parse(R"({"a": [{"b": [4, 5, 60]}], "c": {"d": {"e": 7}}})"));
|
||||
|
||||
// a value replaced above the path that was resolved before
|
||||
CHECK(doc.patch(json::parse(R"([
|
||||
const json replaced_above = json::parse(R"([
|
||||
{"op": "test", "path": "/c/d/e", "value": 7},
|
||||
{"op": "replace", "path": "/c/d", "value": {"e": 8, "f": {"g": 9}}},
|
||||
{"op": "test", "path": "/c/d/e", "value": 8},
|
||||
@@ -2708,7 +2710,8 @@ TEST_CASE("JSON patch - consecutive operations with paths that share a prefix")
|
||||
{"op": "remove", "path": "/c/d/f"},
|
||||
{"op": "add", "path": "/c/d/f", "value": [1]},
|
||||
{"op": "test", "path": "/c/d/f/0", "value": 1}
|
||||
])")) == json::parse(R"({"a": [{"b": [1, 2, 3]}, {"b": [4, 5, 6]}], "c": {"d": {"e": 8, "f": [1]}}})"));
|
||||
])");
|
||||
CHECK(doc.patch(replaced_above) == json::parse(R"({"a": [{"b": [1, 2, 3]}, {"b": [4, 5, 6]}], "c": {"d": {"e": 8, "f": [1]}}})"));
|
||||
|
||||
#if !defined(JSON_NOEXCEPTION)
|
||||
// a value removed above the path that was resolved before is gone
|
||||
|
||||
Reference in new issue
Block a user