From 13356095c5cf115bea4fb7ce77906fb9bcf29fc7 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Tue, 3 Dec 2024 21:30:18 -0500 Subject: [PATCH] jsoncons::utility::uri -> jsoncons::uri --- doc/ref/jsonschema/make_json_schema.md | 3 +- include/jsoncons/utility/uri.hpp | 11 ++---- .../jsonschema/common/compilation_context.hpp | 6 +-- .../jsonschema/common/keyword_validators.hpp | 2 +- .../jsonschema/common/schema_builder.hpp | 10 ++--- .../jsonschema/common/schema_validators.hpp | 28 +++++++------- .../jsonschema/common/uri_wrapper.hpp | 14 +++---- .../jsonschema/common/validator.hpp | 4 +- .../draft201909/schema_builder_201909.hpp | 6 +-- .../draft202012/schema_builder_202012.hpp | 16 ++++---- .../jsonschema/draft4/schema_builder_4.hpp | 2 +- .../jsonschema/draft6/schema_builder_6.hpp | 2 +- .../jsonschema/draft7/schema_builder_7.hpp | 2 +- .../jsonschema/json_schema_factory.hpp | 22 +++++------ test/corelib/src/utility/uri_tests.cpp | 38 +++++++++---------- .../src/jsonschema_draft4_tests.cpp | 2 +- 16 files changed, 81 insertions(+), 87 deletions(-) diff --git a/doc/ref/jsonschema/make_json_schema.md b/doc/ref/jsonschema/make_json_schema.md index cd103d769..c98c40529 100644 --- a/doc/ref/jsonschema/make_json_schema.md +++ b/doc/ref/jsonschema/make_json_schema.md @@ -57,8 +57,7 @@ Returns a [json_schema](json_schema.md) that represents a compiled JSON Sc resolve A function object with the signature of resolve being equivalent to
-    Json fun(const jsoncons::uri& uri)                   (until 0.178.0)
-    Json fun(const jsoncons::utility::uri& uri)          (since 1.0.0)
+    Json fun(const jsoncons::uri& uri)  
     
If unable to resolve the resource, it should return Json::null(). diff --git a/include/jsoncons/utility/uri.hpp b/include/jsoncons/utility/uri.hpp index 5dd156eac..bbd925cac 100644 --- a/include/jsoncons/utility/uri.hpp +++ b/include/jsoncons/utility/uri.hpp @@ -16,7 +16,7 @@ #include #include -namespace jsoncons { namespace utility { +namespace jsoncons { enum class uri_errc { @@ -61,17 +61,16 @@ namespace jsoncons { namespace utility { return std::error_code(static_cast(result), uri_error_category()); } -} // namespace utility } // namespace jsoncons namespace std { template<> - struct is_error_code_enum : public true_type + struct is_error_code_enum : public true_type { }; } // namespace std -namespace jsoncons { namespace utility { +namespace jsoncons { struct uri_fragment_part_t { @@ -1235,10 +1234,6 @@ namespace jsoncons { namespace utility { } }; -} // namespace utility - -using uri = utility::uri; - } // namespace jsoncons #endif diff --git a/include/jsoncons_ext/jsonschema/common/compilation_context.hpp b/include/jsoncons_ext/jsonschema/common/compilation_context.hpp index 0e6516287..d60c3b2f4 100644 --- a/include/jsoncons_ext/jsonschema/common/compilation_context.hpp +++ b/include/jsoncons_ext/jsonschema/common/compilation_context.hpp @@ -67,7 +67,7 @@ namespace jsonschema { return base_uri_.uri(); } - jsoncons::utility::uri make_schema_location(const std::string& keyword) const + jsoncons::uri make_schema_location(const std::string& keyword) const { for (auto it = uris_.rbegin(); it != uris_.rend(); ++it) { @@ -79,14 +79,14 @@ namespace jsonschema { return uri{"#"}; } - static jsoncons::utility::uri make_random_uri() + static jsoncons::uri make_random_uri() { std::random_device dev; std::mt19937 gen{ dev() }; std::uniform_int_distribution dist(1, 10000); std::string str = "https:://jsoncons.com/" + std::to_string(dist(gen)); - jsoncons::utility::uri uri{str}; + jsoncons::uri uri{str}; return uri; } }; diff --git a/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp b/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp index c040ec7d2..b48ebe0d0 100644 --- a/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp +++ b/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp @@ -145,7 +145,7 @@ namespace jsonschema { void set_referred_schema(const schema_validator* target) final { tentative_target_ = target; } - const jsoncons::utility::uri& value() const { return value_.uri(); } + const jsoncons::uri& value() const { return value_.uri(); } uri get_base_uri() const { diff --git a/include/jsoncons_ext/jsonschema/common/schema_builder.hpp b/include/jsoncons_ext/jsonschema/common/schema_builder.hpp index 384847094..ab4fc3ea8 100644 --- a/include/jsoncons_ext/jsonschema/common/schema_builder.hpp +++ b/include/jsoncons_ext/jsonschema/common/schema_builder.hpp @@ -16,13 +16,13 @@ namespace jsoncons { namespace jsonschema { template - using schema_resolver = std::function; + using schema_resolver = std::function; template class schema_builder { public: - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; using schema_builder_factory_type = std::function>(const Json&, const evaluation_options&,schema_store_type*,const std::vector>&, const std::unordered_map&)>; @@ -46,8 +46,8 @@ namespace jsonschema { // Owns external schemas std::vector schema_validators_; public: - std::vector> unresolved_refs_; - std::map unknown_keywords_; + std::vector> unresolved_refs_; + std::map unknown_keywords_; public: @@ -195,7 +195,7 @@ namespace jsonschema { { // is there a reference looking for this unknown-keyword, which is thus no longer a unknown keyword but a schema auto unresolved_refs = std::find_if(this->unresolved_refs_.begin(), this->unresolved_refs_.end(), - [new_uri](const std::pair*>& pr) {return pr.first == new_uri.uri();}); + [new_uri](const std::pair*>& pr) {return pr.first == new_uri.uri();}); if (unresolved_refs != this->unresolved_refs_.end()) { anchor_uri_map_type anchor_dict2; diff --git a/include/jsoncons_ext/jsonschema/common/schema_validators.hpp b/include/jsoncons_ext/jsonschema/common/schema_validators.hpp index 0021beb66..c021d49e0 100644 --- a/include/jsoncons_ext/jsonschema/common/schema_validators.hpp +++ b/include/jsoncons_ext/jsonschema/common/schema_validators.hpp @@ -56,12 +56,12 @@ namespace jsonschema { return schema_val_->recursive_anchor(); } - const jsoncons::optional& id() const final + const jsoncons::optional& id() const final { return schema_val_->id(); } - const jsoncons::optional& dynamic_anchor() const final + const jsoncons::optional& dynamic_anchor() const final { return schema_val_->dynamic_anchor(); } @@ -119,9 +119,9 @@ namespace jsonschema { uri schema_location_; bool value_; - jsoncons::optional id_; + jsoncons::optional id_; - jsoncons::optional dynamic_anchor_; + jsoncons::optional dynamic_anchor_; public: boolean_schema_validator(const boolean_schema_validator&) = delete; @@ -148,12 +148,12 @@ namespace jsonschema { return false; } - const jsoncons::optional& id() const final + const jsoncons::optional& id() const final { return id_; } - const jsoncons::optional& dynamic_anchor() const final + const jsoncons::optional& dynamic_anchor() const final { return dynamic_anchor_; } @@ -209,14 +209,14 @@ namespace jsonschema { using walk_reporter_type = typename json_schema_traits::walk_reporter_type; uri schema_location_; - jsoncons::optional id_; + jsoncons::optional id_; std::vector validators_; std::unique_ptr> unevaluated_properties_val_; std::unique_ptr> unevaluated_items_val_; std::map defs_; Json default_value_; bool recursive_anchor_; - jsoncons::optional dynamic_anchor_; + jsoncons::optional dynamic_anchor_; anchor_schema_map_type anchor_dict_; bool always_succeeds_; bool always_fails_; @@ -227,7 +227,7 @@ namespace jsonschema { object_schema_validator(object_schema_validator&&) = default; object_schema_validator& operator=(object_schema_validator&&) = default; object_schema_validator(const uri& schema_location, - const jsoncons::optional& id, + const jsoncons::optional& id, std::vector&& validators, std::map&& defs, Json&& default_value) @@ -242,7 +242,7 @@ namespace jsonschema { init(); } object_schema_validator(const uri& schema_location, - const jsoncons::optional& id, + const jsoncons::optional& id, std::vector&& validators, std::unique_ptr>&& unevaluated_properties_val, std::unique_ptr>&& unevaluated_items_val, @@ -261,13 +261,13 @@ namespace jsonschema { init(); } object_schema_validator(const uri& schema_location, - const jsoncons::optional& id, + const jsoncons::optional& id, std::vector&& validators, std::unique_ptr>&& unevaluated_properties_val, std::unique_ptr>&& unevaluated_items_val, std::map&& defs, Json&& default_value, - jsoncons::optional&& dynamic_anchor, + jsoncons::optional&& dynamic_anchor, anchor_schema_map_type&& anchor_dict) : schema_location_(schema_location), id_(std::move(id)), @@ -299,7 +299,7 @@ namespace jsonschema { return recursive_anchor_; } - const jsoncons::optional& id() const final + const jsoncons::optional& id() const final { return id_; } @@ -310,7 +310,7 @@ namespace jsonschema { return (it == anchor_dict_.end()) ? nullptr : it->second->referred_schema(); } - const jsoncons::optional& dynamic_anchor() const final + const jsoncons::optional& dynamic_anchor() const final { return dynamic_anchor_; } diff --git a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp index feb2652d6..bdfd4c472 100644 --- a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp +++ b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp @@ -18,7 +18,7 @@ namespace jsonschema { class uri_wrapper { - jsoncons::utility::uri uri_; + jsoncons::uri uri_; std::string identifier_; bool has_plain_name_fragment_; public: @@ -29,7 +29,7 @@ namespace jsonschema { explicit uri_wrapper(const std::string& uri) { - uri_ = jsoncons::utility::uri(uri); + uri_ = jsoncons::uri(uri); if (!uri_.encoded_fragment().empty()) { identifier_ = uri_.fragment(); @@ -46,7 +46,7 @@ namespace jsonschema { explicit uri_wrapper(const uri& uri) : uri_{uri} { - uri_ = jsoncons::utility::uri(uri); + uri_ = jsoncons::uri(uri); if (!uri_.encoded_fragment().empty()) { identifier_ = uri_.fragment(); @@ -60,7 +60,7 @@ namespace jsonschema { } } - const jsoncons::utility::uri& uri() const + const jsoncons::uri& uri() const { return uri_; } @@ -75,7 +75,7 @@ namespace jsonschema { return has_plain_name_fragment_; } - jsoncons::utility::uri base() const + jsoncons::uri base() const { return uri_.base(); } @@ -118,7 +118,7 @@ namespace jsonschema { jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.encoded_fragment())); pointer /= field; - jsoncons::utility::uri new_uri(uri_, utility::uri_fragment_part, pointer.to_string()); + jsoncons::uri new_uri(uri_, uri_fragment_part, pointer.to_string()); return uri_wrapper(std::move(new_uri)); } @@ -131,7 +131,7 @@ namespace jsonschema { jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.encoded_fragment())); pointer /= index; - jsoncons::utility::uri new_uri(uri_, utility::uri_fragment_part, pointer.to_string()); + jsoncons::uri new_uri(uri_, uri_fragment_part, pointer.to_string()); return uri_wrapper(std::move(new_uri)); } diff --git a/include/jsoncons_ext/jsonschema/common/validator.hpp b/include/jsoncons_ext/jsonschema/common/validator.hpp index b53044d69..075094465 100644 --- a/include/jsoncons_ext/jsonschema/common/validator.hpp +++ b/include/jsoncons_ext/jsonschema/common/validator.hpp @@ -426,11 +426,11 @@ namespace jsonschema { virtual bool recursive_anchor() const = 0; - virtual const jsoncons::optional& id() const = 0; + virtual const jsoncons::optional& id() const = 0; virtual const schema_validator* get_schema_for_dynamic_anchor(const std::string& anchor) const = 0; - virtual const jsoncons::optional& dynamic_anchor() const = 0; + virtual const jsoncons::optional& dynamic_anchor() const = 0; }; } // namespace jsonschema diff --git a/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp b/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp index de8b076d6..51904d2f9 100644 --- a/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp +++ b/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp @@ -239,7 +239,7 @@ namespace draft201909 { schema_validator_type make_object_schema_validator( const compilation_context& context, const Json& sch, anchor_uri_map_type& anchor_dict) { - jsoncons::optional id = context.id(); + jsoncons::optional id = context.id(); Json default_value{ jsoncons::null_type()}; std::vector validators; std::unique_ptr> unevaluated_properties_val; @@ -523,8 +523,8 @@ namespace draft201909 { { JSONCONS_THROW(schema_error("Invalid $anchor " + anchor)); } - auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::utility::uri{"#"}; - jsoncons::utility::uri new_uri(uri, utility::uri_fragment_part, anchor); + auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"}; + jsoncons::uri new_uri(uri, uri_fragment_part, anchor); uri_wrapper identifier{ new_uri }; if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end()) { diff --git a/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp b/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp index 48e6eb34c..026bb14ac 100644 --- a/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp +++ b/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp @@ -239,12 +239,12 @@ namespace draft202012 { schema_validator_type make_object_schema_validator(const compilation_context& context, const Json& sch, anchor_uri_map_type& anchor_dict) { - jsoncons::optional id = context.id(); + jsoncons::optional id = context.id(); Json default_value{jsoncons::null_type()}; std::vector validators; std::unique_ptr> unevaluated_properties_val; std::unique_ptr> unevaluated_items_val; - jsoncons::optional dynamic_anchor; + jsoncons::optional dynamic_anchor; std::map defs; anchor_uri_map_type local_anchor_dict; @@ -252,8 +252,8 @@ namespace draft202012 { if (it != sch.object_range().end()) { std::string value = it->value().template as(); - jsoncons::utility::uri new_uri(context.get_base_uri(), utility::uri_fragment_part, value); - dynamic_anchor = jsoncons::optional(new_uri); + jsoncons::uri new_uri(context.get_base_uri(), uri_fragment_part, value); + dynamic_anchor = jsoncons::optional(new_uri); local_anchor_dict.emplace(value, context.get_base_uri()); } @@ -578,8 +578,8 @@ namespace draft202012 { { JSONCONS_THROW(schema_error("Invalid $anchor " + anchor)); } - auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::utility::uri{"#"}; - jsoncons::utility::uri new_uri(uri, utility::uri_fragment_part, anchor); + auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"}; + jsoncons::uri new_uri(uri, uri_fragment_part, anchor); uri_wrapper identifier{ new_uri }; if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end()) { @@ -594,8 +594,8 @@ namespace draft202012 { { JSONCONS_THROW(schema_error("Invalid $dynamicAnchor " + anchor)); } - auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::utility::uri{"#"}; - jsoncons::utility::uri new_uri(uri, utility::uri_fragment_part, anchor); + auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"}; + jsoncons::uri new_uri(uri, uri_fragment_part, anchor); uri_wrapper identifier{ new_uri }; if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end()) { diff --git a/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp b/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp index eec711ff2..2914cde57 100644 --- a/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp +++ b/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp @@ -187,7 +187,7 @@ namespace draft4 { schema_validator_type make_object_schema_validator(const compilation_context& context, const Json& sch, anchor_uri_map_type& anchor_dict) { - jsoncons::optional id = context.id(); + jsoncons::optional id = context.id(); Json default_value{ jsoncons::null_type() }; std::vector validators; std::map defs; diff --git a/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp b/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp index eaf97fa81..f0a09e74b 100644 --- a/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp +++ b/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp @@ -198,7 +198,7 @@ namespace draft6 { schema_validator_type make_object_schema_validator(const compilation_context& context, const Json& sch, anchor_uri_map_type& anchor_dict) { - jsoncons::optional id = context.id(); + jsoncons::optional id = context.id(); Json default_value{ jsoncons::null_type() }; std::vector validators; std::map defs; diff --git a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp index a64b0c5b0..00387cecc 100644 --- a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp +++ b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp @@ -201,7 +201,7 @@ namespace draft7 { schema_validator_type make_object_schema_validator(const compilation_context& context, const Json& sch, anchor_uri_map_type& anchor_dict) { - jsoncons::optional id = context.id(); + jsoncons::optional id = context.id(); Json default_value{ jsoncons::null_type() }; std::vector validators; std::map defs; diff --git a/include/jsoncons_ext/jsonschema/json_schema_factory.hpp b/include/jsoncons_ext/jsonschema/json_schema_factory.hpp index 8f0bcb07d..5ebc75478 100644 --- a/include/jsoncons_ext/jsonschema/json_schema_factory.hpp +++ b/include/jsoncons_ext/jsonschema/json_schema_factory.hpp @@ -20,7 +20,7 @@ namespace jsonschema { class schema_builder_factory { public: - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_builder_factory() { @@ -145,7 +145,7 @@ namespace jsonschema { std::unique_ptr> builder; bool found = false; - jsoncons::utility::uri uri{ std::string(schema_id) }; + jsoncons::uri uri{ std::string(schema_id) }; for (auto it = resolvers.begin(); it != resolvers.end() && !found; ++it) { Json meta_sch = (*it)(uri.base()); @@ -178,7 +178,7 @@ namespace jsonschema { }; template - Json meta_resolver(const jsoncons::utility::uri& uri) + Json meta_resolver(const jsoncons::uri& uri) { if (uri.base() == schema_version::draft202012()) { @@ -211,7 +211,7 @@ namespace jsonschema { make_json_schema(Json sch, const std::string& retrieval_uri, const ResolveURI& resolve, evaluation_options options = evaluation_options{}) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -227,7 +227,7 @@ namespace jsonschema { json_schema make_json_schema(Json sch, const std::string& retrieval_uri, evaluation_options options = evaluation_options{}) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -244,7 +244,7 @@ namespace jsonschema { make_json_schema(Json sch, const ResolveURI& resolve, evaluation_options options = evaluation_options{}) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -260,7 +260,7 @@ namespace jsonschema { json_schema make_json_schema(Json sch, evaluation_options options = evaluation_options{}) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -279,7 +279,7 @@ namespace jsonschema { typename std::enable_if::value,std::shared_ptr>>::type make_schema(Json sch, const std::string& retrieval_uri, const ResolveURI& resolve) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -296,7 +296,7 @@ namespace jsonschema { template std::shared_ptr> make_schema(Json sch, const std::string& retrieval_uri) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -314,7 +314,7 @@ namespace jsonschema { typename std::enable_if::value,std::shared_ptr>>::type make_schema(Json sch, const ResolveURI& resolve) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; @@ -331,7 +331,7 @@ namespace jsonschema { template std::shared_ptr> make_schema(Json sch) { - using schema_store_type = std::map*>; + using schema_store_type = std::map*>; schema_store_type schema_store; schema_builder_factory builder_factory{}; diff --git a/test/corelib/src/utility/uri_tests.cpp b/test/corelib/src/utility/uri_tests.cpp index 3444b46f4..2e4eef825 100644 --- a/test/corelib/src/utility/uri_tests.cpp +++ b/test/corelib/src/utility/uri_tests.cpp @@ -351,7 +351,7 @@ TEST_CASE("uri constructors") { jsoncons::uri x{"http://localhost:4242/draft2019-09/recursiveRef6/base.json"}; - jsoncons::uri y{ x, jsoncons::utility::uri_fragment_part, "/anyOf" }; + jsoncons::uri y{ x, jsoncons::uri_fragment_part, "/anyOf" }; jsoncons::uri expected{"http://localhost:4242/draft2019-09/recursiveRef6/base.json#/anyOf"}; @@ -384,102 +384,102 @@ TEST_CASE("cpp-netlib uri tests") SECTION("test_empty_path") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56", ec); REQUIRE_FALSE(ec); CHECK(uri.encoded_path().empty()); } SECTION("test_empty_path_with_query") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56?query", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56?query", ec); REQUIRE_FALSE(ec); CHECK(uri.encoded_path().empty()); } SECTION("test_empty_path_with_fragment") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56#fragment", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56#fragment", ec); REQUIRE_FALSE(ec); CHECK(uri.encoded_path().empty()); } SECTION("test_single_slash") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56/", ec); REQUIRE_FALSE(ec); CHECK("/" == uri.encoded_path()); } SECTION("test_single_slash_with_query") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/?query", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56/?query", ec); REQUIRE_FALSE(ec); CHECK("/" == uri.encoded_path()); } SECTION("test_single_slash_with_fragment") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/#fragment", ec); + jsoncons::uri uri = jsoncons::uri::parse("http://123.34.23.56/#fragment", ec); REQUIRE_FALSE(ec); CHECK("/" == uri.encoded_path()); } SECTION("test_double_slash_empty_path_empty_everything") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file://", ec); - REQUIRE(ec == jsoncons::utility::uri_errc::invalid_uri); + jsoncons::uri uri = jsoncons::uri::parse("file://", ec); + REQUIRE(ec == jsoncons::uri_errc::invalid_uri); CHECK(uri.encoded_path().empty()); } SECTION("test_triple_slash_empty_everything") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file:///", ec); + jsoncons::uri uri = jsoncons::uri::parse("file:///", ec); REQUIRE_FALSE(ec); CHECK("/" == uri.encoded_path()); } SECTION("test_triple_slash_with_path_name") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file:///path", ec); + jsoncons::uri uri = jsoncons::uri::parse("file:///path", ec); REQUIRE_FALSE(ec); CHECK("/path" == uri.encoded_path()); } SECTION("test_rootless_1") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example.com", ec); + jsoncons::uri uri = jsoncons::uri::parse("mailto:john.doe@example.com", ec); REQUIRE_FALSE(ec); CHECK("john.doe@example.com" == uri.encoded_path()); } SECTION("test_invalid_characters_in_path") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:jo%hn.doe@example.com", ec); + jsoncons::uri uri = jsoncons::uri::parse("mailto:jo%hn.doe@example.com", ec); REQUIRE(ec); - REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec); + REQUIRE(jsoncons::uri_errc::invalid_characters_in_path == ec); //std::cout << ec.message() << "\n"; } SECTION("test_invalid_percent_encoded_characters_in_path_1") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example%G0.com", ec); + jsoncons::uri uri = jsoncons::uri::parse("mailto:john.doe@example%G0.com", ec); REQUIRE(ec); - REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec); + REQUIRE(jsoncons::uri_errc::invalid_characters_in_path == ec); //std::cout << ec.message() << "\n"; } SECTION("test_invalid_percent_encoded_characters_in_path_2") { std::error_code ec; - jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example%0G.com", ec); + jsoncons::uri uri = jsoncons::uri::parse("mailto:john.doe@example%0G.com", ec); REQUIRE(ec); - REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec); + REQUIRE(jsoncons::uri_errc::invalid_characters_in_path == ec); //std::cout << ec.message() << "\n"; } } TEST_CASE("cpp-netib uri resolve tests") { - jsoncons::utility::uri base_uri{"http://a/b/c/d;p?q"}; + jsoncons::uri base_uri{"http://a/b/c/d;p?q"}; SECTION("is_absolute_uri__returns_other") { diff --git a/test/jsonschema/src/jsonschema_draft4_tests.cpp b/test/jsonschema/src/jsonschema_draft4_tests.cpp index e90fbadfd..3fb8ee0d0 100644 --- a/test/jsonschema/src/jsonschema_draft4_tests.cpp +++ b/test/jsonschema/src/jsonschema_draft4_tests.cpp @@ -16,7 +16,7 @@ namespace jsonschema = jsoncons::jsonschema; namespace { - json resolve(const jsoncons::utility::uri& uri) + json resolve(const jsoncons::uri& uri) { //std::cout << uri.string() << ", " << uri.path() << "\n"; std::string pathname = "./jsonschema/JSON-Schema-Test-Suite/remotes";