Skip to content

Commit

Permalink
sort_descending
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Nov 21, 2023
1 parent 31d76d1 commit ebd3549
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/jsonpath/src/jsonpath_make_expression_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ TEST_CASE("jsonpath make_expression tests")
CHECK(doc["books"][3].contains("price"));
CHECK(doc["books"][3].at("price") == 140);
}

SECTION("update default sort order")
{
json doc = json::parse(input);

auto expr = jsoncons::jsonpath::make_expression<json>("$.books[*]");

std::vector<jsonpath::path_node> path_nodes;
auto callback2 = [&](const jsonpath::path_node& base_node, json&)
{
path_nodes.push_back(base_node);
};

expr.update(doc, callback2);

REQUIRE(path_nodes.size() == 4);
CHECK(path_nodes[0].index() == 3);
CHECK(path_nodes[1].index() == 2);
CHECK(path_nodes[2].index() == 1);
CHECK(path_nodes[3].index() == 0);
}
}

TEST_CASE("jsonpath legacy make_expression test")
Expand Down

0 comments on commit ebd3549

Please sign in to comment.