Skip to content

Commit

Permalink
json_location
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Nov 15, 2023
1 parent 8fa34fc commit 0378626
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

// See https://github.com/danielaparker/jsoncons for latest version

#ifndef JSONCONS_JSON_LOCATION_HPP
#define JSONCONS_JSON_LOCATION_HPP
#ifndef JSONCONS_JSONPATH_JSON_LOCATION_HPP
#define JSONCONS_JSONPATH_JSON_LOCATION_HPP

#include <string>
#include <vector>
Expand All @@ -17,6 +17,7 @@
#include <jsoncons/extension_traits.hpp>

namespace jsoncons {
namespace jsonpath {

enum class path_element_kind { name, index };

Expand Down Expand Up @@ -234,6 +235,7 @@ namespace jsoncons {
using path_element = basic_path_element<char,std::allocator<char>>;
using wpath_element = basic_path_element<wchar_t,std::allocator<char>>;

} // namespace jsonpath
} // namespace jsoncons

#endif
2 changes: 1 addition & 1 deletion include/jsoncons_ext/jsonpath/path_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <vector>
#include <functional>
#include <algorithm> // std::reverse
#include <jsoncons/json_location.hpp>
#include <jsoncons_ext/jsonpath/json_location.hpp>
#include <jsoncons/config/jsoncons_config.hpp>
#include <jsoncons/detail/write_number.hpp>
#include <jsoncons_ext/jsonpath/jsonpath_error.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_executable(unit_tests
mergepatch/src/mergepatch_test_suite.cpp
jsonpatch/src/jsonpatch_test_suite.cpp
jsonpatch/src/jsonpatch_tests.cpp
jsonpath/src/json_location_tests.cpp
jsonpath/src/jsonpath_flatten_tests.cpp
jsonpath/src/path_node_tests.cpp
jsonpath/src/jsonpath_custom_function_tests.cpp
Expand Down Expand Up @@ -141,7 +142,6 @@ add_executable(unit_tests
corelib/src/json_less_tests.cpp
corelib/src/json_line_split_tests.cpp
corelib/src/json_literal_operator_tests.cpp
corelib/src/json_location_tests.cpp
corelib/src/json_object_tests.cpp
corelib/src/ojson_object_tests.cpp
corelib/src/json_options_tests.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json_location.hpp>
#include <jsoncons_ext/jsonpath/json_location.hpp>
#include <catch/catch.hpp>
#include <iostream>

Expand All @@ -11,14 +11,14 @@ TEST_CASE("test json_location")
{
SECTION("test 1")
{
json_location loc;
jsonpath::json_location loc;
loc /= "foo";
loc /= 1;

CHECK(loc.size() == 2);
CHECK(loc[0].element_kind() == path_element_kind::name);
CHECK(loc[0].element_kind() == jsonpath::path_element_kind::name);
CHECK(loc[0].name() == "foo");
CHECK(loc[1].element_kind() == path_element_kind::index);
CHECK(loc[1].element_kind() == jsonpath::path_element_kind::index);
CHECK(loc[1].index() == 1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/jsonpath/src/path_node_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ TEST_CASE("test to_json_location")
jsonpath::path_node a3(&a2,"bar");
jsonpath::path_node a4(&a3,7);

jsoncons::json_location location;
jsonpath::json_location location;
location /= "foo";
location /= "bar";
location /= 7;
Expand Down

0 comments on commit 0378626

Please sign in to comment.