Skip to content

Commit

Permalink
json_pointer_arg -> json_reference_arg
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Nov 18, 2024
1 parent 88de90a commit 8baf629
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 200 deletions.
335 changes: 164 additions & 171 deletions include/jsoncons/basic_json.hpp

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion include/jsoncons/json_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace jsoncons {
half_float = 6, // 0110
short_str = 7, // 0111
json_const_pointer = 8, // 1000
json_pointer = 9, // 1001
json_reference = 9, // 1001
byte_str = 12, // 1100
object = 13, // 1101
array = 14, // 1110
Expand Down Expand Up @@ -143,6 +143,7 @@ namespace jsoncons {
static constexpr const CharT* empty_object_value = JSONCONS_CSTRING_CONSTANT(CharT, "empty_object");
static constexpr const CharT* object_value = JSONCONS_CSTRING_CONSTANT(CharT, "object");
static constexpr const CharT* json_const_pointer = JSONCONS_CSTRING_CONSTANT(CharT, "json_const_pointer");
static constexpr const CharT* json_reference = JSONCONS_CSTRING_CONSTANT(CharT, "json_reference");

switch (storage)
{
Expand Down Expand Up @@ -211,6 +212,11 @@ namespace jsoncons {
os << json_const_pointer;
break;
}
case json_storage_kind::json_reference:
{
os << json_reference;
break;
}
}
return os;
}
Expand Down
6 changes: 3 additions & 3 deletions include/jsoncons/tag_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ struct json_const_pointer_arg_t

constexpr json_const_pointer_arg_t json_const_pointer_arg{};

struct json_pointer_arg_t
struct json_reference_arg_t
{
explicit json_pointer_arg_t() = default;
explicit json_reference_arg_t() = default;
};

constexpr json_pointer_arg_t json_pointer_arg{};
constexpr json_reference_arg_t json_reference_arg{};

enum class semantic_tag : uint8_t
{
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ add_executable(unit_tests
corelib/src/json_checker_tests.cpp
corelib/src/json_comparator_tests.cpp
corelib/src/json_const_pointer_arg_tests.cpp
corelib/src/json_pointer_arg_tests.cpp
corelib/src/json_reference_arg_tests.cpp
corelib/src/json_assignment_tests.cpp
corelib/src/json_constructor_tests.cpp
corelib/src/json_cursor_tests.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@ TEST_CASE("json_pointer array tests")

SECTION("size()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_array());
CHECK(v.size() == 3);
CHECK_FALSE(v.empty());
}
SECTION("at()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_array());
REQUIRE_NOTHROW(v.at(1));
}
SECTION("copy")
{
json v(json_pointer_arg, &j);
CHECK(v.storage_kind() == json_storage_kind::json_pointer);
json v(json_reference_arg, j);
CHECK(v.storage_kind() == json_storage_kind::json_reference);

json j2(v);
CHECK(j2.storage_kind() == json_storage_kind::json_pointer);
CHECK(j2.storage_kind() == json_storage_kind::json_reference);
}
SECTION("assignment")
{
json v(json_pointer_arg, &j);
CHECK(v.storage_kind() == json_storage_kind::json_pointer);
json v(json_reference_arg, j);
CHECK(v.storage_kind() == json_storage_kind::json_reference);

json j2;
j2 = v;
CHECK(j2.storage_kind() == json_storage_kind::json_pointer);
CHECK(j2.storage_kind() == json_storage_kind::json_reference);
}
SECTION("push_back")
{
json expected = json::parse(R"( ["one", "two", "three", "four"] )");

json v(json_pointer_arg, &j);
CHECK(v.storage_kind() == json_storage_kind::json_pointer);
json v(json_reference_arg, j);
CHECK(v.storage_kind() == json_storage_kind::json_reference);
j.push_back("four");

CHECK(expected == v);
Expand All @@ -61,8 +61,8 @@ TEST_CASE("json_pointer array tests")
{
json expected = json::parse(R"( ["one", "two", "three", "four"] )");

json v(json_pointer_arg, &j);
CHECK(v.storage_kind() == json_storage_kind::json_pointer);
json v(json_reference_arg, j);
CHECK(v.storage_kind() == json_storage_kind::json_reference);
j.emplace_back("four");

CHECK(expected == v);
Expand All @@ -75,14 +75,14 @@ TEST_CASE("json_pointer object tests")

SECTION("size()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_object());
CHECK(v.size() == 3);
CHECK_FALSE(v.empty());
}
SECTION("at()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_object());
REQUIRE_NOTHROW(v.at("two"));
CHECK(v.contains("two"));
Expand All @@ -99,7 +99,7 @@ TEST_CASE("json_pointer string tests")

SECTION("is_string()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_string());
REQUIRE(v.is_string_view());

Expand All @@ -114,7 +114,7 @@ TEST_CASE("json_pointer byte_string tests")

SECTION("is_byte_string()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_byte_string());
REQUIRE(v.is_byte_string_view());
}
Expand All @@ -127,13 +127,13 @@ TEST_CASE("json_pointer bool tests")

SECTION("true")
{
json v(json_pointer_arg, &tru);
json v(json_reference_arg, tru);
REQUIRE(v.is_bool());
CHECK(v.as_bool());
}
SECTION("false")
{
json v(json_pointer_arg, &fal);
json v(json_reference_arg, fal);
REQUIRE(v.is_bool());
CHECK_FALSE(v.as_bool());
}
Expand All @@ -145,7 +145,7 @@ TEST_CASE("json_pointer int64 tests")

SECTION("is_int64()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_int64());
CHECK(v.as<int64_t>() == -100);
}
Expand All @@ -157,7 +157,7 @@ TEST_CASE("json_pointer uint64 tests")

SECTION("is_uint64()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_uint64());
CHECK(v.as<uint64_t>() == 100);
}
Expand All @@ -169,7 +169,7 @@ TEST_CASE("json_pointer half tests")

SECTION("is_half()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_half());
CHECK(v.as<uint16_t>() == 100);
}
Expand All @@ -181,7 +181,7 @@ TEST_CASE("json_pointer double tests")

SECTION("is_double()")
{
json v(json_pointer_arg, &j);
json v(json_reference_arg, j);
REQUIRE(v.is_double());

CHECK(v.as_double() == 123.456);
Expand Down
4 changes: 2 additions & 2 deletions test/corelib/src/json_storage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST_CASE("test json_storage_kind")
CHECK(is_trivial_storage(json_storage_kind::short_str));
CHECK(is_trivial_storage(json_storage_kind::empty_object));
CHECK(is_trivial_storage(json_storage_kind::json_const_pointer));
CHECK(is_trivial_storage(json_storage_kind::json_pointer));
CHECK(is_trivial_storage(json_storage_kind::json_reference));
CHECK_FALSE(is_trivial_storage(json_storage_kind::long_str));
CHECK_FALSE(is_trivial_storage(json_storage_kind::byte_str));
CHECK_FALSE(is_trivial_storage(json_storage_kind::array));
Expand All @@ -37,7 +37,7 @@ TEST_CASE("test json_storage_kind")
CHECK(is_string_storage(json_storage_kind::short_str));
CHECK_FALSE(is_string_storage(json_storage_kind::empty_object));
CHECK_FALSE(is_string_storage(json_storage_kind::json_const_pointer));
CHECK_FALSE(is_string_storage(json_storage_kind::json_pointer));
CHECK_FALSE(is_string_storage(json_storage_kind::json_reference));
CHECK(is_string_storage(json_storage_kind::long_str));
CHECK_FALSE(is_string_storage(json_storage_kind::byte_str));
CHECK_FALSE(is_string_storage(json_storage_kind::array));
Expand Down

0 comments on commit 8baf629

Please sign in to comment.