mirror of
https://github.com/nlohmann/json.git
synced 2026-05-13 17:55:23 +00:00
* Added front, pop_front, and push_front methods to json_pointers in order to facilitate root-to-leaf traversals of JSON object trees. (#4889) Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> * undid VS autoformatting in irrelevant code Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> * Ran make amalgamate, added navigation to json_pointer's new front methods in mkdocs, and fixed errors in documented complexity for those methods. Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> * Fixed GCC 4.8 compile error caused by const iterators Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> * Fixed another gcc-4.8 compile error Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> * amalgamated Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com> --------- Signed-off-by: trdesilva <5818730+trdesilva@users.noreply.github.com>
This commit is contained in:
@@ -564,6 +564,14 @@ TEST_CASE("JSON pointers")
|
||||
CHECK(!ptr.empty());
|
||||
CHECK(j[ptr] == j["answer"]["everything"]);
|
||||
|
||||
ptr.pop_front();
|
||||
CHECK(ptr.front() == "everything");
|
||||
ptr.pop_front();
|
||||
CHECK(ptr.empty());
|
||||
ptr.push_front("everything");
|
||||
ptr.push_front(answer);
|
||||
CHECK(j[ptr] == j["answer"]["everything"]);
|
||||
|
||||
// check access via const pointer
|
||||
const auto cptr = ptr;
|
||||
CHECK(cptr.back() == "everything");
|
||||
@@ -588,8 +596,17 @@ TEST_CASE("JSON pointers")
|
||||
CHECK(ptr.empty());
|
||||
CHECK(j[ptr] == j);
|
||||
|
||||
CHECK_THROWS_WITH(ptr.pop_back(),
|
||||
"[json.exception.out_of_range.405] JSON pointer has no parent");
|
||||
CHECK_THROWS_WITH_AS(ptr.pop_back(),
|
||||
"[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&);
|
||||
|
||||
CHECK_THROWS_WITH_AS(ptr.back(),
|
||||
"[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&);
|
||||
|
||||
CHECK_THROWS_WITH_AS(ptr.pop_front(),
|
||||
"[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&);
|
||||
|
||||
CHECK_THROWS_WITH_AS(ptr.front(),
|
||||
"[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&);
|
||||
}
|
||||
|
||||
SECTION("operators")
|
||||
|
||||
Reference in New Issue
Block a user