summaryrefslogtreecommitdiff
path: root/graphics/asymptote/LspCpp/third_party/uri/test
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-02-06 03:01:17 +0000
committerNorbert Preining <norbert@preining.info>2022-02-06 03:01:17 +0000
commit350b3e35109171f0edd6fe9d697b91d5e76561f9 (patch)
treec6eac90d0b35dec36fa17ee58b736e55d6e42755 /graphics/asymptote/LspCpp/third_party/uri/test
parent08ccf305ee79ab8e5ba9d1a8f3d22e74dccedd80 (diff)
CTAN sync 202202060301
Diffstat (limited to 'graphics/asymptote/LspCpp/third_party/uri/test')
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/CMakeLists.txt39
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/invalid_urls.txt39
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/optional_test.cpp168
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/string_utility.hpp17
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/test_uri.hpp99
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_builder_test.cpp855
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_comparison_test.cpp88
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_encoding_test.cpp147
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_normalization_test.cpp212
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_path_test.cpp121
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_scheme_test.cpp79
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_test.cpp565
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_reference_test.cpp68
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_resolve_test.cpp307
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_stream_test.cpp48
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/uri_test.cpp1071
-rw-r--r--graphics/asymptote/LspCpp/third_party/uri/test/valid_urls.txt36
17 files changed, 3959 insertions, 0 deletions
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/CMakeLists.txt b/graphics/asymptote/LspCpp/third_party/uri/test/CMakeLists.txt
new file mode 100644
index 0000000000..0834f6b79c
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (c) Glyn Matthews 2012-2016.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+
+include_directories( ${gtest_SOURCE_DIR}/include)
+
+set(
+ TESTS
+ uri_parse_test
+ uri_parse_scheme_test
+ uri_parse_path_test
+ uri_test
+ uri_encoding_test
+ uri_normalization_test
+ uri_comparison_test
+ uri_reference_test
+ uri_resolve_test
+ uri_builder_test
+ uri_stream_test
+ optional_test
+ )
+
+foreach (test ${TESTS})
+ add_executable(${test} ${test}.cpp)
+ add_dependencies(${test} network-uri gtest_main)
+ target_link_libraries(${test} ${CMAKE_THREAD_LIBS_INIT} network-uri gtest_main)
+ if (OPENSSL_FOUND)
+ target_link_libraries(${test} ${OPENSSL_LIBRARIES})
+ endif()
+ set_target_properties(${test}
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${Uri_BINARY_DIR}/tests)
+ add_test(${test}
+ ${Uri_BINARY_DIR}/tests/${test})
+endforeach (test)
+
+file(GLOB URI_LISTS *.txt)
+file(COPY ${URI_LISTS} DESTINATION ${Uri_BINARY_DIR}/test)
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/invalid_urls.txt b/graphics/asymptote/LspCpp/third_party/uri/test/invalid_urls.txt
new file mode 100644
index 0000000000..fb9ddd3792
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/invalid_urls.txt
@@ -0,0 +1,39 @@
+http://
+http://.
+http://..
+http://../
+http://?
+http://??
+http://??/
+http://#
+http://##
+http://##/
+http://foo.bar?q=Spaces should be encoded
+//
+//a
+///a
+///
+http:///a
+foo.com
+rdar://1234
+h://test
+http:// shouldfail.com
+:// should fail
+http://foo.bar/foo(bar)baz quux
+ftps://foo.bar/
+http://-error-.invalid/
+http://a.b--c.de/
+http://-a.b.co
+http://a.b-.co
+http://0.0.0.0
+http://10.1.1.0
+http://10.1.1.255
+http://224.1.1.1
+http://1.1.1.1.1
+http://123.123.123
+http://3628126748
+http://.www.foo.bar/
+http://www.foo.bar./
+http://.www.foo.bar./
+http://10.1.1.1
+http://10.1.1.254
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/optional_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/optional_test.cpp
new file mode 100644
index 0000000000..32170fd04b
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/optional_test.cpp
@@ -0,0 +1,168 @@
+// Copyright (c) Glyn Matthews 2016.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <string>
+#include <network/optional.hpp>
+#include <network/string_view.hpp>
+
+TEST(optional_test, empty_optional) {
+ network::optional<int> opt;
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, empty_optional_constructed_with_nullopt) {
+ network::optional<int> opt{network::nullopt};
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, empty_optional_string) {
+ network::optional<std::string> opt{};
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, empty_optional_string_with_nullopt) {
+ network::optional<std::string> opt{network::nullopt};
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, value_constructor) {
+ network::optional<int> opt{42};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, value_constructor_string) {
+ network::optional<std::string> opt{"banana"};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, rvalue_ref_constructor) {
+ int value = 42;
+ network::optional<int> opt{std::move(value)};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, rvalue_ref_constructor_string) {
+ std::string value = "banana";
+ network::optional<std::string> opt{std::move(value)};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, nullopt_copy_constructor) {
+ network::optional<int> other{network::nullopt};
+ network::optional<int> opt{other};
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, nullopt_move_constructor) {
+ network::optional<int> other{network::nullopt};
+ network::optional<int> opt{std::move(other)};
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, value_copy_constructor) {
+ network::optional<int> other{42};
+ network::optional<int> opt{other};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, value_move_constructor) {
+ network::optional<int> other{42};
+ network::optional<int> opt{std::move(other)};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, value_copy_constructor_string) {
+ network::optional<std::string> other{"banana"};
+ network::optional<std::string> opt{other};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, value_move_constructor_string) {
+ network::optional<std::string> other{"banana"};
+ network::optional<std::string> opt{std::move(other)};
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, nullopt_assignment) {
+ network::optional<int> opt(42);
+ opt = network::nullopt;
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, nullopt_assignment_string) {
+ network::optional<std::string> opt("banana");
+ opt = network::nullopt;
+ ASSERT_FALSE(opt);
+}
+
+TEST(optional_test, value_copy_assigment) {
+ network::optional<int> opt{};
+ network::optional<int> other{42};
+ opt = other;
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, value_move_assignment) {
+ network::optional<int> opt{};
+ network::optional<int> other{42};
+ opt = std::move(other);
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, 42);
+}
+
+TEST(optional_test, value_copy_assignment_string) {
+ network::optional<std::string> opt{};
+ network::optional<std::string> other{"banana"};
+ opt = other;
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, value_move_assignment_string) {
+ network::optional<std::string> opt{};
+ network::optional<std::string> other{"banana"};
+ opt = std::move(other);
+ ASSERT_TRUE(opt);
+ ASSERT_EQ(*opt, "banana");
+}
+
+TEST(optional_test, value_or_reference) {
+ network::optional<std::string> opt;
+ auto result = opt.value_or("other");
+ ASSERT_EQ("other", result);
+}
+
+TEST(optional_test, value_or_reference_with_value) {
+ network::optional<std::string> opt("this");
+ auto result = opt.value_or("other");
+ ASSERT_EQ("this", result);
+}
+
+TEST(optional_test, value_or_rvalue_reference) {
+ std::string other("other");
+ auto result = network::optional<std::string>().value_or(other);
+ ASSERT_EQ("other", result);
+}
+
+TEST(optional_test, value_or_rvalue_reference_with_value) {
+ std::string other("other");
+ auto result = network::optional<std::string>("this").value_or(other);
+ ASSERT_EQ("this", result);
+}
+
+TEST(optional_test, assign_nullopt_to_nullopt) {
+ network::optional<std::string> opt;
+ opt = network::nullopt;
+} \ No newline at end of file
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/string_utility.hpp b/graphics/asymptote/LspCpp/third_party/uri/test/string_utility.hpp
new file mode 100644
index 0000000000..71d22746bb
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/string_utility.hpp
@@ -0,0 +1,17 @@
+// Copyright 2013-2016 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef URI_TEST_STRING_UTILITY_INC
+#define URI_TEST_STRING_UTILITY_INC
+
+#include <network/string_view.hpp>
+
+namespace network {
+inline bool operator==(const char *lhs, string_view rhs) {
+ return string_view(lhs) == rhs;
+}
+} // namespace network
+
+#endif // URI_TEST_STRING_UTILITY_INC
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/test_uri.hpp b/graphics/asymptote/LspCpp/third_party/uri/test/test_uri.hpp
new file mode 100644
index 0000000000..73726f73c9
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/test_uri.hpp
@@ -0,0 +1,99 @@
+// Copyright 2016 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef TEST_URI_INC
+#define TEST_URI_INC
+
+#include <iterator>
+#include <network/uri/detail/uri_parts.hpp>
+#include "../src/detail/uri_parse.hpp"
+
+using network::detail::parse;
+using network::detail::uri_part;
+using network::detail::uri_parts;
+
+namespace test {
+struct uri {
+
+ explicit uri(const std::string &uri)
+ : uri_(uri), view(uri_) {
+ it = std::begin(view);
+ last = std::end(view);
+ }
+
+ bool parse_uri() {
+ return parse(it, last, parts);
+ }
+
+ std::string parsed_till() const {
+ return std::string(std::begin(view), it);
+ }
+
+ bool has_scheme() const {
+ return static_cast<bool>(parts.scheme);
+ }
+
+ std::string scheme() const {
+ return (*parts.scheme).to_string();
+ }
+
+ bool has_user_info() const {
+ return static_cast<bool>(parts.hier_part.user_info);
+ }
+
+ std::string user_info() const {
+ return (*parts.hier_part.user_info).to_string();
+ }
+
+ bool has_host() const {
+ return static_cast<bool>(parts.hier_part.host);
+ }
+
+ std::string host() const {
+ return (*parts.hier_part.host).to_string();
+ }
+
+ bool has_port() const {
+ return static_cast<bool>(parts.hier_part.port);
+ }
+
+ std::string port() const {
+ return (*parts.hier_part.port).to_string();
+ }
+
+ bool has_path() const {
+ return static_cast<bool>(parts.hier_part.path);
+ }
+
+ std::string path() const {
+ return (*parts.hier_part.path).to_string();
+ }
+
+ bool has_query() const {
+ return static_cast<bool>(parts.query);
+ }
+
+ std::string query() const {
+ return (*parts.query).to_string();
+ }
+
+ bool has_fragment() const {
+ return static_cast<bool>(parts.fragment);
+ }
+
+ std::string fragment() const {
+ return (*parts.fragment).to_string();
+ }
+
+ std::string uri_;
+ network::string_view view;
+ network::string_view::const_iterator it, last;
+
+ uri_parts parts;
+
+};
+} // namespace test
+
+#endif // TEST_URI_INC
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_builder_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_builder_test.cpp
new file mode 100644
index 0000000000..54e29e0c5c
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_builder_test.cpp
@@ -0,0 +1,855 @@
+// Copyright (c) Glyn Matthews 2012-2016.
+// Copyright 2012 Google, Inc.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+#include "string_utility.hpp"
+
+TEST(builder_test, empty_uri_doesnt_throw) {
+ network::uri_builder builder;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, empty_uri) {
+ network::uri_builder builder;
+ network::uri instance(builder);
+ ASSERT_TRUE(instance.empty());
+}
+
+TEST(builder_test, simple_uri_doesnt_throw) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, simple_uri) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, simple_uri_has_scheme) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_TRUE(builder.uri().has_scheme());
+}
+
+TEST(builder_test, simple_uri_scheme_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("http", builder.uri().scheme());
+}
+
+TEST(builder_test, simple_uri_has_no_user_info) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_FALSE(builder.uri().has_user_info());
+}
+
+TEST(builder_test, simple_uri_has_host) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_TRUE(builder.uri().has_host());
+}
+
+TEST(builder_test, simple_uri_host_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("www.example.com", builder.uri().host());
+}
+
+TEST(builder_test, simple_uri_has_no_port) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_FALSE(builder.uri().has_port());
+}
+
+TEST(builder_test, simple_uri_has_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_TRUE(builder.uri().has_path());
+}
+
+TEST(builder_test, simple_uri_path_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("/", builder.uri().path());
+}
+
+TEST(builder_test, simple_uri_has_no_query) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_FALSE(builder.uri().has_query());
+}
+
+TEST(builder_test, simple_uri_has_no_fragment) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_FALSE(builder.uri().has_fragment());
+}
+
+TEST(builder_test, simple_opaque_uri_doesnt_throw) {
+ network::uri_builder builder;
+ builder
+ .scheme("mailto")
+ .path("john.doe@example.com")
+ ;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, simple_opaque_uri) {
+ network::uri_builder builder;
+ builder
+ .scheme("mailto")
+ .path("john.doe@example.com")
+ ;
+ ASSERT_EQ("mailto:john.doe@example.com", builder.uri().string());
+}
+
+TEST(builder_test, simple_opaque_uri_has_scheme) {
+ network::uri_builder builder;
+ builder
+ .scheme("mailto")
+ .path("john.doe@example.com")
+ ;
+ ASSERT_TRUE(builder.uri().has_scheme());
+}
+
+TEST(builder_test, simple_opaque_uri_scheme_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("mailto")
+ .path("john.doe@example.com")
+ ;
+ ASSERT_EQ("mailto", builder.uri().scheme());
+}
+
+TEST(builder_test, relative_hierarchical_uri_doesnt_throw) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, relative_hierarchical_uri) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, relative_opaque_uri_doesnt_throw) {
+ network::uri_builder builder;
+ builder
+ .path("john.doe@example.com")
+ ;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, relative_opaque_uri) {
+ network::uri_builder builder;
+ builder
+ .path("john.doe@example.com")
+ ;
+ ASSERT_EQ("john.doe@example.com", builder.uri().string());
+}
+
+TEST(builder_test, full_uri_doesnt_throw) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_NO_THROW(builder.uri());
+}
+
+TEST(builder_test, full_uri) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("http://user@www.example.com:80/path?query=value#fragment", builder.uri().string());
+}
+
+TEST(builder_test, full_uri_has_scheme) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_scheme());
+}
+
+TEST(builder_test, full_uri_scheme_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("http", builder.uri().scheme());
+}
+
+TEST(builder_test, full_uri_has_user_info) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_user_info());
+}
+
+TEST(builder_test, full_uri_user_info_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("user", builder.uri().user_info());
+}
+
+TEST(builder_test, full_uri_has_host) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_host());
+}
+
+TEST(builder_test, full_uri_host_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("www.example.com", builder.uri().host());
+}
+
+TEST(builder_test, full_uri_has_port) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_port());
+}
+
+TEST(builder_test, full_uri_has_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_path());
+}
+
+TEST(builder_test, full_uri_path_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("/path", builder.uri().path());
+}
+
+TEST(builder_test, full_uri_has_query) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_query());
+}
+
+TEST(builder_test, full_uri_query_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("query=value", builder.uri().query());
+}
+
+TEST(builder_test, full_uri_has_fragment) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_TRUE(builder.uri().has_fragment());
+}
+
+TEST(builder_test, full_uri_fragment_value) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .user_info("user")
+ .host("www.example.com")
+ .port("80")
+ .path("/path")
+ .append_query_key_value_pair("query", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("fragment", builder.uri().fragment());
+}
+
+TEST(builder_test, relative_uri) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, relative_uri_scheme) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_FALSE(builder.uri().has_scheme());
+}
+
+TEST(builder_test, authority) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .authority("www.example.com:8080")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com:8080/", builder.uri().string());
+ ASSERT_EQ("www.example.com", builder.uri().host());
+ ASSERT_EQ("8080", builder.uri().port());
+}
+
+TEST(builder_test, relative_uri_has_host) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_TRUE(builder.uri().has_host());
+}
+
+TEST(builder_test, relative_uri_host_value) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("www.example.com", builder.uri().host());
+}
+
+TEST(builder_test, relative_uri_has_path) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_TRUE(builder.uri().has_path());
+}
+
+TEST(builder_test, relative_uri_path_value) {
+ network::uri_builder builder;
+ builder
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("/", builder.uri().path());
+}
+
+TEST(builder_test, build_relative_uri_with_path_query_and_fragment) {
+ network::uri_builder builder;
+ builder
+ .path("/path/")
+ .append_query_key_value_pair("key", "value")
+ .fragment("fragment")
+ ;
+ ASSERT_EQ("/path/", builder.uri().path());
+ ASSERT_EQ("key=value", builder.uri().query());
+ ASSERT_EQ("fragment", builder.uri().fragment());
+}
+
+TEST(builder_test, build_uri_with_capital_scheme) {
+ network::uri_builder builder;
+ builder
+ .scheme("HTTP")
+ .host("www.example.com")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_capital_host) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("WWW.EXAMPLE.COM")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_unencoded_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/A path with spaces")
+ ;
+ ASSERT_EQ("http://www.example.com/A%20path%20with%20spaces", builder.uri().string());
+}
+
+TEST(builder_test, DISABLED_builder_uri_and_remove_dot_segments_from_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/A/./path/")
+ ;
+ ASSERT_EQ("http://www.example.com/A/path/", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_qmark_in_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/?/")
+ ;
+ ASSERT_EQ("http://www.example.com/%3F/", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_hash_in_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .path("/#/")
+ ;
+ ASSERT_EQ("http://www.example.com/%23/", builder.uri().string());
+}
+
+TEST(builder_test, simple_port) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .port(8000)
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com:8000/", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_query_item) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .append_query_key_value_pair("a", "1")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/?a=1", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_multiple_query_items) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .append_query_key_value_pair("a", "1")
+ .append_query_key_value_pair("b", "2")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/?a=1&b=2", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_query_item_with_encoded_chars)
+{
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .append_query_key_value_pair("a", "parameter with encoded chars!")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/?a=parameter%20with%20encoded%20chars%21", builder.uri().string());
+}
+
+TEST(builder_test, build_uri_with_multiple_query_items_with_encoded_chars) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("www.example.com")
+ .append_query_key_value_pair("a", "first parameter with encoded chars!")
+ .append_query_key_value_pair("b", "second parameter with encoded chars!")
+ .path("/")
+ ;
+ ASSERT_EQ("http://www.example.com/?a=first%20parameter%20with%20encoded%20chars%21&b=second%20parameter%20with%20encoded%20chars%21", builder.uri().string());
+}
+
+TEST(builder_test, construct_from_existing_uri) {
+ network::uri instance("http://www.example.com/");
+ network::uri_builder builder(instance);
+ ASSERT_EQ("http://www.example.com/", builder.uri().string());
+}
+
+TEST(builder_test, build_from_existing_uri) {
+ network::uri instance("http://www.example.com/");
+ network::uri_builder builder(instance);
+ builder.append_query_key_value_pair("a", "1").append_query_key_value_pair("b", "2").fragment("fragment");
+ ASSERT_EQ("http://www.example.com/?a=1&b=2#fragment", builder.uri().string());
+}
+
+TEST(builder_test, authority_without_port_test) {
+ network::uri_builder builder;
+ builder
+ .scheme("https")
+ .authority("www.example.com")
+ ;
+ ASSERT_EQ("www.example.com", builder.uri().authority());
+}
+
+TEST(builder_test, authority_with_port_test) {
+ network::uri_builder builder;
+ builder
+ .scheme("https")
+ .authority("www.example.com:")
+ ;
+ ASSERT_EQ("www.example.com:", builder.uri().authority());
+}
+
+TEST(builder_test, DISABLED_authority_without_host_test) {
+ network::uri_builder builder;
+ builder
+ .scheme("https")
+ .authority(":1234")
+ ;
+ ASSERT_EQ(":1234", builder.uri().authority());
+}
+
+TEST(builder_test, clear_user_info_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ network::uri_builder builder(instance);
+ builder.clear_user_info();
+ ASSERT_EQ("http://www.example.com:80/path?query#fragment", builder.uri().string());
+}
+
+TEST(builder_test, clear_port_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ network::uri_builder builder(instance);
+ builder.clear_port();
+ ASSERT_EQ("http://user@www.example.com/path?query#fragment", builder.uri().string());
+}
+
+TEST(builder_test, clear_path_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ network::uri_builder builder(instance);
+ builder.clear_path();
+ ASSERT_EQ("http://user@www.example.com:80?query#fragment", builder.uri().string());
+}
+
+TEST(builder_test, clear_query_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ network::uri_builder builder(instance);
+ builder.clear_query();
+ ASSERT_EQ("http://user@www.example.com:80/path#fragment", builder.uri().string());
+}
+
+TEST(uri_test, clear_query_params_with_no_query) {
+ network::uri original("http://example.com/path");
+ network::uri_builder builder(original);
+ builder.clear_query();
+}
+
+TEST(builder_test, clear_fragment_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ network::uri_builder builder(instance);
+ builder.clear_fragment();
+ ASSERT_EQ("http://user@www.example.com:80/path?query", builder.uri().string());
+}
+
+TEST(builder_test, empty_username) {
+ std::string user_info(":");
+ network::uri_builder builder;
+ builder.scheme("ftp").host("127.0.0.1").user_info(user_info);
+ ASSERT_EQ("ftp://:@127.0.0.1", builder.uri().string());
+}
+
+TEST(builder_test, path_should_be_prefixed_with_slash) {
+ std::string path("relative");
+ network::uri_builder builder;
+ builder.scheme("ftp").host("127.0.0.1").path(path);
+ ASSERT_EQ("ftp://127.0.0.1/relative", builder.uri().string());
+}
+
+TEST(builder_test, path_should_be_prefixed_with_slash_2) {
+ network::uri_builder builder;
+ builder
+ .scheme("ftp").host("127.0.0.1").path("noleadingslash/foo.txt");
+ ASSERT_EQ("/noleadingslash/foo.txt", builder.uri().path());
+}
+
+TEST(builder_test, set_multiple_query_with_encoding) {
+ network::uri_builder builder;
+ builder
+ .scheme("http")
+ .host("example.com")
+ .append_query_key_value_pair("q1", "foo bar")
+ .append_query_key_value_pair("q2", "biz baz")
+ ;
+ ASSERT_EQ("http://example.com?q1=foo%20bar&q2=biz%20baz", builder.uri().string());
+}
+
+TEST(builder_test, non_array_string_literals_should_work) {
+ const char* p = "http";
+ const char* q = "foo";
+
+ network::uri_builder builder;
+ builder
+ .scheme(p)
+ .host("example.com")
+ .path(q)
+ ;
+ ASSERT_EQ("http://example.com/foo", builder.uri());
+}
+
+TEST(builder_test, non_const_non_array_string_literals_should_work) {
+ const char* p = "http";
+ const char* q = "foo";
+
+ network::uri_builder builder;
+ builder
+ .scheme(const_cast<char *>(p))
+ .host("example.com")
+ .path(const_cast<char *>(q))
+ ;
+ ASSERT_EQ("http://example.com/foo", builder.uri());
+}
+
+TEST(builder_test, scheme_and_absolute_path) {
+ network::uri_builder builder;
+ builder
+ .scheme("foo")
+ .path("/bar")
+ ;
+ ASSERT_EQ("foo:/bar", builder.uri());
+ ASSERT_EQ("foo", builder.uri().scheme());
+ ASSERT_EQ("/bar", builder.uri().path());
+}
+
+TEST(builder_test, assignment_operator_bug_116) {
+ // https://github.com/cpp-netlib/uri/issues/116
+ network::uri a("http://a.com:1234");
+ ASSERT_TRUE(a.has_port());
+
+ const network::uri b("http://b.com");
+ ASSERT_FALSE(b.has_port());
+
+ a = b;
+ ASSERT_FALSE(a.has_port()) << a.string();
+}
+
+TEST(builder_test, construct_from_uri_bug_116) {
+ // https://github.com/cpp-netlib/uri/issues/116
+ network::uri a("http://a.com:1234");
+ const network::uri b("http://b.com");
+ a = b;
+
+ network::uri_builder ub(a);
+ const network::uri c(ub.uri());
+ ASSERT_FALSE(c.has_port()) << c.string();
+}
+
+TEST(builder_test, append_query_value) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_component("q"));
+ ASSERT_EQ(network::string_view("q"), ub.uri().query_begin()->first);
+}
+
+TEST(builder_test, append_query_value_encodes_equal_sign) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_component("="));
+ ASSERT_EQ(network::string_view("%3D"), ub.uri().query_begin()->first);
+}
+
+TEST(builder_test, append_query_key_value_pair_encodes_equals_sign) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "="));
+ ASSERT_EQ(network::string_view("q"), ub.uri().query_begin()->first);
+ ASSERT_EQ(network::string_view("%3D"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, append_query_key_value_pair_encodes_number_sign) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "#"));
+ ASSERT_EQ(network::string_view("%23"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, append_query_key_value_pair_encodes_percent_sign) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "%"));
+ ASSERT_EQ(network::string_view("%25"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, append_query_key_value_pair_encodes_ampersand) {
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "&"));
+ ASSERT_EQ(network::string_view("%26"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, append_query_key_value_pair_does_not_encode_slash) {
+ // https://tools.ietf.org/html/rfc3986#section-3.4
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "/"));
+ ASSERT_EQ(network::string_view("/"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, append_query_key_value_pair_does_not_encode_qmark) {
+ // https://tools.ietf.org/html/rfc3986#section-3.4
+ network::uri_builder ub(network::uri("http://example.com"));
+ ASSERT_NO_THROW(ub.append_query_key_value_pair("q", "?"));
+ ASSERT_EQ(network::string_view("?"), ub.uri().query_begin()->second);
+}
+
+TEST(builder_test, build_from_uri_with_encoded_user_info) {
+ network::uri_builder ub(network::uri("http://%40@example.com"));
+ ASSERT_EQ(network::string_view("%40"), ub.uri().user_info());
+}
+
+TEST(builder_test, build_from_uri_with_encoded_query) {
+ network::uri_builder ub(network::uri("http://example.com?x=%40"));
+ ASSERT_EQ(network::string_view("x=%40"), ub.uri().query());
+}
+
+TEST(builder_test, build_from_uri_with_encoded_fragment) {
+ network::uri_builder ub(network::uri("http://example.com#%40"));
+ ASSERT_EQ(network::string_view("%40"), ub.uri().fragment());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_comparison_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_comparison_test.cpp
new file mode 100644
index 0000000000..67ca4363d0
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_comparison_test.cpp
@@ -0,0 +1,88 @@
+// Copyright (c) Glyn Matthews 2012-2016.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+
+
+TEST(uri_comparison_test, equality_test) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("http://www.example.com/");
+ ASSERT_EQ(lhs, rhs);
+}
+
+TEST(uri_comparison_test, equality_test_capitalized_scheme) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("HTTP://www.example.com/");
+ ASSERT_NE(lhs.compare(rhs, network::uri_comparison_level::string_comparison), 0);
+}
+
+TEST(uri_comparison_test, equality_test_capitalized_scheme_with_case_normalization) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("HTTP://www.example.com/");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+TEST(uri_comparison_test, DISABLED_equality_test_capitalized_host) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("http://WWW.EXAMPLE.COM/");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+TEST(uri_comparison_test, equality_test_with_single_dot_segment) {
+ network::uri lhs("http://www.example.com/./path");
+ network::uri rhs("http://www.example.com/path");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+TEST(uri_comparison_test, equality_test_with_double_dot_segment) {
+ network::uri lhs("http://www.example.com/1/../2/");
+ network::uri rhs("http://www.example.com/2/");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+TEST(uri_comparison_test, DISABLED_given_example_test) {
+ network::uri lhs("example://a/b/c/%7Bfoo%7D");
+ network::uri rhs("eXAMPLE://a/./b/../b/%63/%7bfoo%7d");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+TEST(uri_comparison_test, equality_empty_lhs) {
+ network::uri lhs;
+ network::uri rhs("http://www.example.com/");
+ ASSERT_NE(lhs, rhs);
+}
+
+TEST(uri_comparison_test, equality_empty_rhs) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs;
+ ASSERT_NE(lhs, rhs);
+}
+
+TEST(uri_comparison_test, inequality_test) {
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("http://www.example.com/");
+ ASSERT_FALSE(lhs != rhs);
+}
+
+TEST(uri_comparison_test, less_than_test) {
+ // lhs is lexicographically less than rhs
+ network::uri lhs("http://www.example.com/");
+ network::uri rhs("http://www.example.org/");
+ ASSERT_LT(lhs, rhs);
+}
+
+TEST(uri_comparison_test, percent_encoded_query_reserved_chars) {
+ network::uri lhs("http://www.example.com?foo=%5cbar");
+ network::uri rhs("http://www.example.com?foo=%5Cbar");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
+
+
+TEST(uri_comparison_test, percent_encoded_query_unreserved_chars) {
+ network::uri lhs("http://www.example.com?foo=%61%6c%70%68%61%31%32%33%2d%2e%5f%7e");
+ network::uri rhs("http://www.example.com?foo=alpha123-._~");
+ ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_encoding_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_encoding_test.cpp
new file mode 100644
index 0000000000..47bb4fdd43
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_encoding_test.cpp
@@ -0,0 +1,147 @@
+// Copyright (c) Glyn Matthews 2011-2016.
+// Copyright 2012 Google, Inc.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+#include <iterator>
+
+
+TEST(uri_encoding_test, encode_user_info_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_user_info(std::begin(unencoded), std::end(unencoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C%2F:%3B%3D%3F%40%5B%5D", instance);
+}
+
+TEST(uri_encoding_test, encode_host_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_host(std::begin(unencoded), std::end(unencoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C%2F:%3B%3D%3F%40[]", instance);
+}
+
+TEST(uri_encoding_test, encode_ipv6_host) {
+ const std::string unencoded("[::1]");
+ std::string instance;
+ network::uri::encode_host(std::begin(unencoded), std::end(unencoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("[::1]", instance);
+}
+
+TEST(uri_encoding_test, encode_port_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_port(std::begin(unencoded), std::end(unencoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D", instance);
+}
+
+TEST(uri_encoding_test, encode_path_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_path(std::begin(unencoded), std::end(unencoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C/%3A;=%3F@%5B%5D", instance);
+}
+
+TEST(uri_encoding_test, encode_query_component_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_query_component(
+ std::begin(unencoded), std::end(unencoded), std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C/%3A%3B%3D?%40%5B%5D", instance);
+}
+
+TEST(uri_encoding_test, encode_fragment_iterator) {
+ const std::string unencoded("!#$&'()*+,/:;=?@[]");
+ std::string instance;
+ network::uri::encode_fragment(
+ std::begin(unencoded), std::end(unencoded), std::back_inserter(instance));
+ ASSERT_EQ("%21%23%24&%27%28%29%2A%2B%2C/%3A;=%3F@%5B%5D", instance);
+}
+
+TEST(uri_encoding_test, decode_iterator) {
+ const std::string encoded("%21%23%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D");
+ std::string instance;
+ network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance));
+ ASSERT_EQ("!#$&'()*+,/:;=?@[]", instance);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_1) {
+ const std::string encoded("%");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_2) {
+ const std::string encoded("%2");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_3) {
+ const std::string encoded("%%%");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_4) {
+ const std::string encoded("%2%");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_5) {
+ const std::string encoded("%G0");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_error_6) {
+ const std::string encoded("%0G");
+ std::string instance;
+ ASSERT_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)),
+ network::percent_decoding_error);
+}
+
+TEST(uri_encoding_test, decode_iterator_not_an_error_1) {
+ const std::string encoded("%20");
+ std::string instance;
+ ASSERT_NO_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)));
+}
+
+TEST(uri_encoding_test, decode_iterator_not_an_error_2) {
+ const std::string encoded("%80");
+ std::string instance;
+ ASSERT_NO_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)));
+}
+
+TEST(uri_encoding_test, decode_accepts_utf8) {
+ const std::string encoded("%EB%B2%95%EC%A0%95%EB%8F%99");
+ std::string instance;
+ ASSERT_NO_THROW(network::uri::decode(std::begin(encoded), std::end(encoded),
+ std::back_inserter(instance)));
+
+ // const std::string unencoded = "법정동";
+ const std::string unencoded = "\xEB\xB2\x95\xEC\xA0\x95\xEB\x8F\x99";
+ ASSERT_EQ(unencoded, instance);
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_normalization_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_normalization_test.cpp
new file mode 100644
index 0000000000..48eb8fd94d
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_normalization_test.cpp
@@ -0,0 +1,212 @@
+// Copyright (c) Glyn Matthews 2012-2016.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+
+// Compare the underlying strings because ``normalize`` is used in the
+// ``uri`` equality operator.
+
+TEST(uri_normalization_test, string_comparison) {
+ network::uri instance("http://www.example.com/");
+ ASSERT_EQ(
+ "http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::string_comparison).string());
+}
+
+TEST(uri_normalization_test, string_comparison_with_case) {
+ network::uri instance("HTTP://www.example.com/");
+ ASSERT_EQ(
+ "HTTP://www.example.com/",
+ instance.normalize(network::uri_comparison_level::string_comparison).string());
+}
+
+TEST(uri_normalization_test, normalize_case_capitalized_scheme) {
+ network::uri instance("HTTP://www.example.com/");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, DISABLED_normalize_case_capitalized_host) {
+ network::uri instance("http://WWW.EXAMPLE.COM/");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, normalize_percent_encoding) {
+ network::uri instance(
+ "http://www%2Eexample%2Ecom/%7E%66%6F%6F%62%61%72%5F%36%39/");
+ ASSERT_EQ("http://www.example.com/~foobar_69/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ normalize_percent_encoding_with_lower_case_elements) {
+ network::uri instance(
+ "http://www%2eexample%2ecom/%7e%66%6f%6f%62%61%72%5f%36%39/");
+ ASSERT_EQ("http://www.example.com/~foobar_69/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, normalize_percent_encoding_is_upper_case) {
+ network::uri instance(
+ "HTTP://www%2Eexample%2Ecom/%7E%66%6F%6F%62%61%72%5F%36%39/");
+ ASSERT_EQ("http://www.example.com/~foobar_69/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_segmented_add_trailing_slash) {
+ network::uri instance("http://www.example.com");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_dont_add_trailing_slash_if_path_is_not_empty) {
+ network::uri instance("http://www.example.com/path");
+ ASSERT_EQ("http://www.example.com/path",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_segmented_remove_dot_segments) {
+ network::uri instance("http://www.example.com/a/./b/");
+ ASSERT_EQ("http://www.example.com/a/b/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_segmented_remove_double_dot_segments) {
+ network::uri instance("http://www.example.com/a/../b/");
+ ASSERT_EQ("http://www.example.com/b/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_dot_segments_with_percent_encoded_dot) {
+ network::uri instance("http://www.example.com/a/%2E/b/");
+ ASSERT_EQ("http://www.example.com/a/b/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_percent_encoded_dots) {
+ network::uri instance("http://www.example.com/a/%2E%2E/b/");
+ ASSERT_EQ("http://www.example.com/b/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_query) {
+ network::uri instance("http://www.example.com/a/../b/?key=value");
+ ASSERT_EQ("http://www.example.com/b/?key=value",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_empty_query) {
+ network::uri instance("http://www.example.com/a/../b/?");
+ ASSERT_EQ("http://www.example.com/b/?",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_fragment) {
+ network::uri instance("http://www.example.com/a/../b/#fragment");
+ ASSERT_EQ("http://www.example.com/b/#fragment",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_empty_fragment) {
+ network::uri instance("http://www.example.com/a/../b/#");
+ ASSERT_EQ("http://www.example.com/b/#",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test,
+ path_segmented_remove_double_dot_segments_with_query_and_fragment) {
+ network::uri instance("http://www.example.com/a/../b/?key=value#fragment");
+ ASSERT_EQ("http://www.example.com/b/?key=value#fragment",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_double_dash) {
+ network::uri instance("http://www.example.com//");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_triple_dash) {
+ network::uri instance("http://www.example.com///");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_depth_below_root) {
+ network::uri instance("http://www.example.com/..");
+ ASSERT_THROW(instance.normalize(network::uri_comparison_level::syntax_based),
+ std::system_error);
+}
+
+TEST(uri_normalization_test, path_depth_below_root_2) {
+ network::uri instance("http://www.example.com/a/../..");
+ ASSERT_THROW(instance.normalize(network::uri_comparison_level::syntax_based),
+ std::system_error);
+}
+
+TEST(uri_normalization_test, path_dash_dot_dash) {
+ network::uri instance("http://www.example.com/./");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_dash_dot_dash_dot) {
+ network::uri instance("http://www.example.com/./.");
+ ASSERT_EQ("http://www.example.com/",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_percent_encoded_reserved) {
+ // :/?#[]@!$&'()*+,;=
+ network::uri instance(
+ "http://www.example.com/%3a%2f%3f%23%5b%5d%40%21%24%26%27%28%29%2a%2b%2c%3b%3d");
+ ASSERT_EQ(
+ "http://www.example.com/%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, path_percent_encoded_unreserved) {
+ network::uri instance("http://www.example.com/alpha123%2d%2e%5f%7e");
+ ASSERT_EQ("http://www.example.com/alpha123-._~",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, query_percent_encoded_reserved) {
+ // :/?#[]@!$&'()*+,;=
+ network::uri instance(
+ "http://www.example.com?foo=%3a%2f%3f%23%5b%5d%40%21%24%26%27%28%29%2a%2b%2c%3b%3d");
+ ASSERT_EQ(
+ "http://www.example.com/?foo=%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_normalization_test, query_percent_encoded_unreserved) {
+ network::uri instance("http://www.example.com?foo=alpha123%2d%2e%5f%7e");
+ ASSERT_EQ("http://www.example.com/?foo=alpha123-._~",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_test, path_adjacent_slashes_122) {
+ // https://github.com/cpp-netlib/uri/issues/122
+ network::uri instance("http://www.example.com/abc//elementary");
+ ASSERT_EQ("http://www.example.com/abc/elementary",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
+
+TEST(uri_test, path_adjacent_slashes_122_part_2) {
+ // https://github.com/cpp-netlib/uri/issues/122
+ network::uri instance("http://www.example.com/abc//.//../elementary");
+ ASSERT_EQ("http://www.example.com/elementary",
+ instance.normalize(network::uri_comparison_level::syntax_based).string());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_path_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_path_test.cpp
new file mode 100644
index 0000000000..168789c3b9
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_path_test.cpp
@@ -0,0 +1,121 @@
+// Copyright 2016 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include "test_uri.hpp"
+#include "string_utility.hpp"
+
+// path = path-abempty ; begins with "/" or is empty
+// / path-absolute ; begins with "/" but not "//"
+// / path-noscheme ; begins with a non-colon segment
+// / path-rootless ; begins with a segment
+// / path-empty ; zero characters
+//
+// path-abempty = *( "/" segment )
+// path-absolute = "/" [ segment-nz *( "/" segment ) ]
+// path-noscheme = segment-nz-nc *( "/" segment )
+// path-rootless = segment-nz *( "/" segment )
+// path-empty = 0<pchar>
+//
+// segment = *pchar
+// segment-nz = 1*pchar
+// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
+// ; non-zero-length segment without any colon ":"
+//
+// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
+
+
+TEST(uri_parse_path_test, test_empty_path) {
+ test::uri uri("http://123.34.23.56");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_TRUE(uri.path().empty());
+}
+
+TEST(uri_parse_path_test, test_empty_path_with_query) {
+ test::uri uri("http://123.34.23.56?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_TRUE(uri.path().empty());
+}
+
+TEST(uri_parse_path_test, test_empty_path_with_fragment) {
+ test::uri uri("http://123.34.23.56#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_TRUE(uri.path().empty());
+}
+
+TEST(uri_parse_path_test, test_single_slash) {
+ test::uri uri("http://123.34.23.56/");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_path_test, test_single_slash_with_query) {
+ test::uri uri("http://123.34.23.56/?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_path_test, test_single_slash_with_fragment) {
+ test::uri uri("http://123.34.23.56/#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_path_test, test_double_slash_empty_path_empty_everything) {
+ test::uri uri("file://");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_path_test, test_triple_slash_empty_everything) {
+ test::uri uri("file:///");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_path_test, test_triple_slash_with_path_name) {
+ test::uri uri("file:///path");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+}
+
+TEST(uri_parse_path_test, test_rootless_1) {
+ test::uri uri("mailto:john.doe@example.com");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("john.doe@example.com", uri.path());
+}
+
+TEST(uri_parse_path_test, test_invalid_characters_in_path) {
+ test::uri uri("mailto:jo%hn.doe@example.com");
+ EXPECT_FALSE(uri.parse_uri());
+ EXPECT_EQ("mailto:jo", uri.parsed_till());
+}
+
+TEST(uri_parse_path_test, test_valid_percent_encoded_characters_in_path) {
+ test::uri uri("mailto:john.doe@example%F0.com");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("john.doe@example%F0.com", uri.path());
+}
+
+TEST(uri_parse_path_test, test_invalid_percent_encoded_characters_in_path_1) {
+ test::uri uri("mailto:john.doe@example%G0.com");
+ EXPECT_FALSE(uri.parse_uri());
+ EXPECT_EQ("mailto:john.doe@example", uri.parsed_till());
+}
+
+TEST(uri_parse_path_test, test_invalid_percent_encoded_characters_in_path_2) {
+ test::uri uri("mailto:john.doe@example%0G.com");
+ EXPECT_FALSE(uri.parse_uri());
+ EXPECT_EQ("mailto:john.doe@example", uri.parsed_till());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_scheme_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_scheme_test.cpp
new file mode 100644
index 0000000000..9801f5c15c
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_scheme_test.cpp
@@ -0,0 +1,79 @@
+// Copyright 2016 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iterator>
+#include <gtest/gtest.h>
+#include "test_uri.hpp"
+#include "string_utility.hpp"
+
+// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+
+TEST(uri_parse_test, test_valid_scheme) {
+ test::uri uri("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_beginning_with_a_colon) {
+ test::uri uri(":http://user@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_scheme());
+}
+
+TEST(uri_parse_test, test_scheme_beginning_with_a_number) {
+ test::uri uri("8http://user@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_minus) {
+ test::uri uri("ht-tp://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("ht-tp", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_plus) {
+ test::uri uri("ht+tp://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("ht+tp", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_dot) {
+ test::uri uri("ht.tp://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("ht.tp", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_number) {
+ test::uri uri("http1://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http1", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_with_an_invalid_character) {
+ test::uri uri("http$://user@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_scheme_with_capital_letters) {
+ test::uri uri("HTTP://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("HTTP", uri.scheme());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_percent) {
+ test::uri uri("ht%tp://user@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_scheme_with_a_valid_percent_encoded_character) {
+ test::uri uri("ht%00tp://user@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_test.cpp
new file mode 100644
index 0000000000..c2acc0a33a
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_parse_test.cpp
@@ -0,0 +1,565 @@
+// Copyright 2016-2017 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <fstream>
+#include <gtest/gtest.h>
+#include "test_uri.hpp"
+#include "string_utility.hpp"
+
+TEST(uri_parse_test, test_empty_uri) {
+ test::uri uri("");
+ EXPECT_FALSE(uri.parse_uri());
+ EXPECT_TRUE(uri.parsed_till().empty());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info) {
+ test::uri uri("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_empty_user_info) {
+ test::uri uri("http://@www.example.com:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_unset_user_info) {
+ test::uri uri("http://www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_unset_user_info_and_host) {
+ test::uri uri("http://:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_FALSE(uri.has_host());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info_and_host) {
+ test::uri uri("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info_unset_host) {
+ test::uri uri("http://user@:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_host());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info_host_and_port) {
+ test::uri uri("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_TRUE(uri.has_port());
+ EXPECT_EQ("80", uri.port());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_empty_user_info_valid_host_and_port) {
+ test::uri uri("http://www.example.com:80/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_TRUE(uri.has_port());
+ EXPECT_EQ("80", uri.port());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_empty_user_info_valid_host_empty_port) {
+ test::uri uri("http://www.example.com/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info_and_host_empty_port) {
+ test::uri uri("http://user@www.example.com/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_info_empty_host_valid_port) {
+ test::uri uri("http://user@:80/path?query#fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_empty_port_empty_path) {
+ test::uri uri("http://www.example.com");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ ASSERT_TRUE(uri.path().empty());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_valid_port_empty_path) {
+ test::uri uri("http://www.example.com:80");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_TRUE(uri.has_port());
+ EXPECT_EQ("80", uri.port());
+ ASSERT_TRUE(uri.has_path());
+ ASSERT_TRUE(uri.path().empty());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_user_odd_digits_port) {
+ test::uri uri("http://user@www.example.com:12345/foo");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_port());
+ EXPECT_EQ("12345", uri.port());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_port_path) {
+ test::uri uri("http://www.example.com:80/path");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_TRUE(uri.has_port());
+ EXPECT_EQ("80", uri.port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_path) {
+ test::uri uri("http://www.example.com/path");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_with_opaque_uri) {
+ test::uri uri("mailto:user@example.com");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("mailto", uri.scheme());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_FALSE(uri.has_host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("user@example.com", uri.path());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_path_and_query) {
+ test::uri uri("http://www.example.com/path?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_path_query_and_fragment) {
+ test::uri uri("http://www.example.com/path?query#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_hierarchical_part_valid_host_path_and_fragment) {
+ test::uri uri("http://www.example.com/path#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path", uri.path());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_invalid_fragment) {
+ test::uri uri("http://www.example.com/path#%fragment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_valid_fragment_with_pct_encoded_char) {
+ test::uri uri("http://www.example.com/path#%ffragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("%ffragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_valid_fragment_with_unreserved_char) {
+ test::uri uri("http://www.example.com/path#fragment-");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment-", uri.fragment());
+}
+
+TEST(uri_parse_test, test_invalid_fragment_with_gen_delim) {
+ test::uri uri("http://www.example.com/path#frag#ment");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_valid_fragment_with_sub_delim) {
+ test::uri uri("http://www.example.com/path#frag$ment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("frag$ment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_valid_fragment_with_forward_slash_and_question_mark) {
+ test::uri uri("http://www.example.com/path#frag/ment?");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("frag/ment?", uri.fragment());
+}
+
+TEST(uri_parse_test, test_invalid_query) {
+ test::uri uri("http://www.example.com/path?%query");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_valid_query_with_pct_encoded_char) {
+ test::uri uri("http://www.example.com/path?%00query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("%00query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_valid_query_with_unreserved_char) {
+ test::uri uri("http://www.example.com/path?query-");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query-", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_valid_query_with_sub_delim) {
+ test::uri uri("http://www.example.com/path?qu$ery");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("qu$ery", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_invalid_port_with_path) {
+ test::uri uri("http://123.34.23.56:6662626/");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_invalid_port) {
+ test::uri uri("http://123.34.23.56:6662626");
+ EXPECT_FALSE(uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_empty_port_with_path) {
+ test::uri uri("http://123.34.23.56:/");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_port());
+ ASSERT_EQ("", uri.port());
+}
+
+TEST(uri_parse_test, test_empty_port) {
+ test::uri uri("http://123.34.23.56:");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_port());
+ ASSERT_EQ("", uri.port());
+}
+
+TEST(uri_parse_test, test_ipv6_address) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A]");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+}
+
+TEST(uri_parse_test, test_ipv6_address_with_path) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A]/");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_test, test_invalid_ipv6_address) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A");
+ EXPECT_FALSE(!uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_invalid_ipv6_address_with_path) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A/");
+ EXPECT_FALSE(!uri.parse_uri());
+}
+
+TEST(uri_parse_test, test_opaque_uri_with_one_slash) {
+ test::uri uri("scheme:/path/");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("scheme", uri.scheme());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/path/", uri.path());
+}
+
+TEST(uri_parse_test, test_empty_query) {
+ test::uri uri("http://www.example.com/?");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("", uri.query());
+}
+
+TEST(uri_parse_test, test_query_with_empty_path) {
+ test::uri uri("http://www.example.com?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_query_with_user_info_and_empty_path) {
+ test::uri uri("http://user@www.example.com?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_fragment_with_empty_path) {
+ test::uri uri("http://www.example.com#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_fragment_with_user_info_and_empty_path) {
+ test::uri uri("http://user@www.example.com#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_query_with_empty_path_and_ipv6_address) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A]?query");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_query_with_user_info_empty_path_and_ipv6_address) {
+ test::uri uri("http://user@[1080:0:0:0:8:800:200C:417A]?query");
+ EXPECT_TRUE(uri.parse_uri());
+ EXPECT_EQ("http://user@[1080:0:0:0:8:800:200C:417A]?query", uri.parsed_till());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_TRUE(uri.has_query());
+ EXPECT_EQ("query", uri.query());
+ ASSERT_FALSE(uri.has_fragment());
+}
+
+TEST(uri_parse_test, test_fragment_with_empty_path_and_ipv6_address) {
+ test::uri uri("http://[1080:0:0:0:8:800:200C:417A]#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_fragment_with_user_info_empty_path_and_ipv6_address) {
+ test::uri uri("http://user@[1080:0:0:0:8:800:200C:417A]#fragment");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", uri.host());
+ ASSERT_FALSE(uri.has_port());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("", uri.path());
+ ASSERT_FALSE(uri.has_query());
+ ASSERT_TRUE(uri.has_fragment());
+ EXPECT_EQ("fragment", uri.fragment());
+}
+
+TEST(uri_parse_test, test_pct_encoded_user_info) {
+ test::uri uri("http://user%3f@www.example.com/");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_TRUE(uri.has_scheme());
+ EXPECT_EQ("http", uri.scheme());
+ ASSERT_TRUE(uri.has_user_info());
+ EXPECT_EQ("user%3f", uri.user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("www.example.com", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/", uri.path());
+}
+
+TEST(uri_parse_test, test_file_uri_bug_98) {
+ test::uri uri("file:///bin/bash");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/bin/bash", uri.path());
+}
+
+TEST(uri_parse_test, test_file_uri_bug_98_2) {
+ test::uri uri("file://localhost/bin");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("localhost", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/bin", uri.path());
+}
+
+TEST(uri_parse_test, test_file_uri_bug_98_3) {
+ test::uri uri("file://localhost/bin/bash");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("localhost", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/bin/bash", uri.path());
+}
+
+TEST(uri_parse_test, test_file_uri_bug_98_4) {
+ test::uri uri("file:///bin");
+ EXPECT_TRUE(uri.parse_uri());
+ ASSERT_FALSE(uri.has_user_info());
+ ASSERT_TRUE(uri.has_host());
+ EXPECT_EQ("", uri.host());
+ ASSERT_TRUE(uri.has_path());
+ EXPECT_EQ("/bin", uri.path());
+}
+
+TEST(uri_parse_test, test_has_host_bug_88) {
+ test::uri uri("http://user@host");
+ EXPECT_TRUE(uri.parse_uri());
+}
+
+// http://formvalidation.io/validators/uri/
+
+std::vector<std::string> create_urls(const std::string &filename) {
+ std::vector<std::string> urls;
+ std::ifstream ifs(filename);
+ if (!ifs) {
+ throw std::runtime_error("Unable to open file: " + filename);
+ }
+ for (std::string url; std::getline(ifs, url);) {
+ if (url.front() != '#') {
+ urls.push_back(url);
+ }
+ }
+ return urls;
+}
+
+// All valid URLs in the list should pass
+class test_valid_urls : public ::testing::TestWithParam<std::string> {};
+
+INSTANTIATE_TEST_CASE_P(uri_parse_test, test_valid_urls,
+ testing::ValuesIn(create_urls("valid_urls.txt")));
+
+TEST_P(test_valid_urls, urls_are_valid) {
+ test::uri uri(GetParam());
+ EXPECT_TRUE(uri.parse_uri());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_reference_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_reference_test.cpp
new file mode 100644
index 0000000000..9eaedb8259
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_reference_test.cpp
@@ -0,0 +1,68 @@
+// Copyright (c) Glyn Matthews 2012-2016.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+
+
+TEST(uri_make_relative_test, opaque_uri) {
+ network::uri uri_1("mailto:glynos@example.com");
+ network::uri uri_2("mailto:john.doe@example.com");
+ ASSERT_EQ(uri_2, uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, simple_test) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/path/");
+ ASSERT_EQ("/path/", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, simple_test_with_different_authority) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.org/path/");
+ ASSERT_EQ("http://www.example.org/path/", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, simple_test_is_relative) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/path/");
+ ASSERT_FALSE(uri_1.make_relative(uri_2).is_absolute());
+}
+
+TEST(uri_make_relative_test, simple_test_is_hierarchical) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/path/");
+ ASSERT_FALSE(uri_1.make_relative(uri_2).is_opaque());
+}
+
+TEST(uri_make_relative_test, simple_test_with_query) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/path/?key=value");
+ ASSERT_EQ("/path/?key=value", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, simple_test_with_fragment) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/path/#fragment");
+ ASSERT_EQ("/path/#fragment", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, make_relative_with_percent_encoding_normalization) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/%7E%66%6F%6F%62%61%72%5F%36%39/");
+ ASSERT_EQ("/~foobar_69/", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, make_relative_with_percent_encoding_normalization_with_query) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/%7E%66%6F%6F%62%61%72%5F%36%39/?key=value");
+ ASSERT_EQ("/~foobar_69/?key=value", uri_1.make_relative(uri_2));
+}
+
+TEST(uri_make_relative_test, make_relative_with_percent_encoding_normalization_with_fragment) {
+ network::uri uri_1("http://www.example.com/");
+ network::uri uri_2("http://www.example.com/%7E%66%6F%6F%62%61%72%5F%36%39/#fragment");
+ ASSERT_EQ("/~foobar_69/#fragment", uri_1.make_relative(uri_2));
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_resolve_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_resolve_test.cpp
new file mode 100644
index 0000000000..8d5b49cb06
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_resolve_test.cpp
@@ -0,0 +1,307 @@
+// Copyright 2012-2016 Glyn Matthews.
+// Copyright 2013 Hannes Kamecke.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+#include "string_utility.hpp"
+
+using namespace network;
+
+struct uri_resolve_test : public ::testing::Test {
+ uri_resolve_test() : base_uri("http://a/b/c/d;p?q")
+ {
+ }
+
+ uri::string_type resolved(const uri& base, const uri& reference) {
+ return reference.resolve(base).string();
+ }
+
+ uri::string_type resolved(const uri& reference)
+ {
+ return resolved(base_uri, reference);
+ }
+
+ network::uri base_uri;
+};
+
+
+TEST_F(uri_resolve_test, is_absolute_uri__returns_other)
+{
+ ASSERT_EQ("https://www.example.com/", resolved(uri("https://www.example.com/")));
+}
+
+TEST_F(uri_resolve_test, base_has_empty_path__path_is_ref_path_1)
+{
+ uri reference = uri_builder().path("g").uri();
+ ASSERT_EQ("http://a/g", resolved(uri("http://a/"), reference));
+}
+
+TEST_F(uri_resolve_test, base_has_empty_path__path_is_ref_path_2)
+{
+ uri reference = uri_builder().path("g/x/y").append_query_key_value_pair("q", "1").fragment("s").uri();
+ ASSERT_EQ("http://a/g/x/y?q=1#s", resolved(uri("http://a/"), reference));
+}
+
+// normal examples
+// http://tools.ietf.org/html/rfc3986#section-5.4.1
+
+TEST_F(uri_resolve_test, remove_dot_segments1) {
+ uri reference = uri_builder().path("./g").uri();
+ ASSERT_EQ("http://a/b/c/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, base_has_path__path_is_merged_1) {
+ uri reference = uri_builder().path("g/").uri();
+ ASSERT_EQ("http://a/b/c/g/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, base_has_path__path_is_merged_2) {
+ uri reference = uri_builder().path("g").uri();
+ ASSERT_EQ("http://a/b/c/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, path_starts_with_slash__path_is_ref_path) {
+ uri reference = uri_builder().path("/g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, path_starts_with_slash_with_query_fragment__path_is_ref_path) {
+ uri reference = uri_builder().path("/g/x").append_query_key_value_pair("y", "z").fragment("s").uri();
+ ASSERT_EQ("http://a/g/x?y=z#s", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, DISABLED_has_authority__base_scheme_with_ref_authority) {
+ // ASSERT_EQ("http://g", resolved("//g"));
+ // uri reference = uri_builder().host("g").path("").uri();
+ uri reference = uri_builder().path("//g").uri();
+ ASSERT_EQ("http://g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, path_is_empty_but_has_query__returns_base_with_ref_query) {
+ uri reference = uri_builder().append_query_key_value_pair("y", "z").uri();
+ ASSERT_EQ("http://a/b/c/d;p?y=z", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, path_is_empty_but_has_query_base_no_query__returns_base_with_ref_query) {
+ uri reference = uri_builder().append_query_key_value_pair("y", "z").uri();
+ ASSERT_EQ("http://a/b/c/d?y=z", resolved(uri("http://a/b/c/d"), reference));
+}
+
+TEST_F(uri_resolve_test, merge_path_with_query) {
+ uri reference = uri_builder().path("g").append_query_key_value_pair("y", "z").uri();
+ ASSERT_EQ("http://a/b/c/g?y=z", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, append_fragment) {
+ uri reference = uri_builder().fragment("s").uri();
+ ASSERT_EQ("http://a/b/c/d;p?q#s", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, merge_paths_with_fragment) {
+ uri reference = uri_builder().path("g").fragment("s").uri();
+ ASSERT_EQ("http://a/b/c/g#s", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, merge_paths_with_query_and_fragment) {
+ uri reference = uri_builder().path("g").append_query_key_value_pair("y", "z").fragment("s").uri();
+ ASSERT_EQ("http://a/b/c/g?y=z#s", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, merge_paths_with_semicolon_1) {
+ uri reference = uri_builder().path(";x").uri();
+ ASSERT_EQ("http://a/b/c/;x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, merge_paths_with_semicolon_2) {
+ uri reference = uri_builder().path("g;x").uri();
+ ASSERT_EQ("http://a/b/c/g;x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, merge_paths_with_semicolon_3) {
+ uri reference = uri_builder().path("g;x").append_query_key_value_pair("y", "z").fragment("s").uri();
+ ASSERT_EQ("http://a/b/c/g;x?y=z#s", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, path_is_empty__returns_base) {
+ uri reference = uri_builder().uri();
+ ASSERT_EQ("http://a/b/c/d;p?q", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments2) {
+ uri reference = uri_builder().path(".").uri();
+ ASSERT_EQ("http://a/b/c/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments3) {
+ uri reference = uri_builder().path("./").uri();
+ ASSERT_EQ("http://a/b/c/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments4) {
+ uri reference = uri_builder().path("..").uri();
+ ASSERT_EQ("http://a/b/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments5) {
+ uri reference = uri_builder().path("../").uri();
+ ASSERT_EQ("http://a/b/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments6) {
+ uri reference = uri_builder().path("../g").uri();
+ ASSERT_EQ("http://a/b/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments7) {
+ uri reference = uri_builder().path("../..").uri();
+ ASSERT_EQ("http://a/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments8) {
+ uri reference = uri_builder().path("../../").uri();
+ ASSERT_EQ("http://a/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, remove_dot_segments9) {
+ uri reference = uri_builder().path("../../g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+
+// abnormal examples
+// http://tools.ietf.org/html/rfc3986#section-5.4.2
+
+TEST_F(uri_resolve_test, abnormal_example_1) {
+ uri reference = uri_builder().path("../../../g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_2) {
+ uri reference = uri_builder().path("../../../../g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_3) {
+ uri reference = uri_builder().path("/./g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_4) {
+ uri reference = uri_builder().path("/../g").uri();
+ ASSERT_EQ("http://a/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_5) {
+ uri reference = uri_builder().path("g.").uri();
+ ASSERT_EQ("http://a/b/c/g.", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_6) {
+ uri reference = uri_builder().path(".g").uri();
+ ASSERT_EQ("http://a/b/c/.g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_7) {
+ uri reference = uri_builder().path("g..").uri();
+ ASSERT_EQ("http://a/b/c/g..", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_8) {
+ uri reference = uri_builder().path("..g").uri();
+ ASSERT_EQ("http://a/b/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_9) {
+ uri reference = uri_builder().path("./../g").uri();
+ ASSERT_EQ("http://a/b/g", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_10) {
+ uri reference = uri_builder().path("./g/.").uri();
+ ASSERT_EQ("http://a/b/c/g/", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_11) {
+ uri reference = uri_builder().path("g/./h").uri();
+ ASSERT_EQ("http://a/b/c/g/h", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_12) {
+ uri reference = uri_builder().path("g/../h").uri();
+ ASSERT_EQ("http://a/b/c/h", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_13) {
+ uri reference = uri_builder().path("g;x=1/./y").uri();
+ ASSERT_EQ("http://a/b/c/g;x=1/y", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_14) {
+ uri reference = uri_builder().path("g;x=1/../y").uri();
+ ASSERT_EQ("http://a/b/c/y", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_15) {
+ uri reference = uri_builder().path("g").append_query_component("y/./x").uri();
+ ASSERT_EQ("http://a/b/c/g?y/./x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_16) {
+ uri reference = uri_builder().path("g").append_query_component("y/../x").uri();
+ ASSERT_EQ("http://a/b/c/g?y/../x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_17) {
+ uri reference = uri_builder().path("g").fragment("s/./x").uri();
+ ASSERT_EQ("http://a/b/c/g#s/./x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, abnormal_example_18) {
+ uri reference = uri_builder().path("g").fragment("s/../x").uri();
+ ASSERT_EQ("http://a/b/c/g#s/../x", resolved(reference));
+}
+
+TEST_F(uri_resolve_test, issue_resolve_from_copy) {
+ // https://github.com/cpp-netlib/uri/issues/15
+ network::uri base("http://a.com/");
+ network::uri uri("http:/example.com/path/");
+ network::uri copy = uri;
+ ASSERT_TRUE(copy.is_opaque());
+ auto result = copy.resolve(base);
+ ASSERT_EQ("http:/example.com/path/", result);
+}
+
+TEST_F(uri_resolve_test, issue_resolve_from_move) {
+ // https://github.com/cpp-netlib/uri/issues/15
+ network::uri base("http://a.com/");
+ network::uri uri("http:/example.com/path/");
+ network::uri copy = std::move(uri);
+ ASSERT_TRUE(copy.is_opaque());
+ auto result = copy.resolve(base);
+ ASSERT_EQ("http:/example.com/path/", result);
+}
+
+TEST_F(uri_resolve_test, issue_15_resolve_from_copy_with_query) {
+ // https://github.com/cpp-netlib/uri/issues/15
+ network::uri base("http://a.com/");
+ network::uri uri("http:/example.com/path/?query#fragment");
+ network::uri copy = uri;
+ ASSERT_TRUE(copy.is_opaque());
+ auto result = copy.resolve(base);
+ ASSERT_EQ("query", uri.query());
+ ASSERT_EQ("query", copy.query());
+ ASSERT_EQ("query", result.query());
+}
+
+TEST_F(uri_resolve_test, issue_15_resolve_from_copy_with_fragment) {
+ // https://github.com/cpp-netlib/uri/issues/15
+ network::uri base("http://a.com/");
+ network::uri uri("http:/example.com/path/?query#fragment");
+ network::uri copy = uri;
+ ASSERT_TRUE(copy.is_opaque());
+ auto result = copy.resolve(base);
+ ASSERT_EQ("fragment", result.fragment());
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_stream_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_stream_test.cpp
new file mode 100644
index 0000000000..4223a119d4
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_stream_test.cpp
@@ -0,0 +1,48 @@
+// Copyright 2013-2016 Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+#include <sstream>
+
+TEST(uri_stream_test, ostream) {
+ std::ostringstream oss;
+ oss << network::uri("http://www.example.com/");
+ ASSERT_EQ("http://www.example.com/", oss.str());
+}
+
+TEST(uri_stream_test, wostream) {
+ std::wostringstream oss;
+ oss << network::uri("http://www.example.com/");
+ ASSERT_EQ(L"http://www.example.com/", oss.str());
+}
+
+TEST(uri_stream_test, istream) {
+ std::istringstream iss("http://www.example.com/");
+ network::uri instance;
+ iss >> instance;
+ ASSERT_EQ("http://www.example.com/", instance);
+}
+
+TEST(uri_stream_test, wistream) {
+ std::wistringstream iss(L"http://www.example.com/");
+ network::uri instance;
+ iss >> instance;
+ ASSERT_EQ("http://www.example.com/", instance);
+}
+
+TEST(uri_stream_test, DISABLED_istream_invalid_uri) {
+ std::istringstream iss("I am not a valid URI.");
+ network::uri instance;
+ ASSERT_THROW((iss >> instance), network::uri_syntax_error);
+}
+
+TEST(uri_stream_test, DISABLED_wistream_invalid_uri) {
+ std::wistringstream iss(L"I am not a valid URI.");
+ network::uri instance;
+ ASSERT_THROW((iss >> instance), network::uri_syntax_error);
+}
+
+// This is not the full story with istream and exceptions...
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/uri_test.cpp b/graphics/asymptote/LspCpp/third_party/uri/test/uri_test.cpp
new file mode 100644
index 0000000000..62e224867a
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/uri_test.cpp
@@ -0,0 +1,1071 @@
+// Copyright 2010 Jeroen Habraken.
+// Copyright 2009-2017 Dean Michael Berris, Glyn Matthews.
+// Copyright 2012 Google, Inc.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <gtest/gtest.h>
+#include <network/uri.hpp>
+#include <algorithm>
+#include <memory>
+#include <map>
+#include <set>
+#include <unordered_set>
+#include "string_utility.hpp"
+
+TEST(uri_test, construct_invalid_uri) {
+ EXPECT_THROW(network::uri("I am not a valid URI."), network::uri_syntax_error);
+}
+
+TEST(uri_test, make_invalid_uri) {
+ std::error_code ec;
+ network::uri uri = network::make_uri("I am not a valid URI.", ec);
+ EXPECT_TRUE(static_cast<bool>(ec));
+}
+
+TEST(uri_test, construct_uri_from_char_array) {
+ EXPECT_NO_THROW(network::uri("http://www.example.com/"));
+}
+
+TEST(uri_test, construct_uri_starting_with_ipv4_like) {
+ EXPECT_NO_THROW(network::uri("http://198.51.100.0.example.com/"));
+}
+
+TEST(uri_test, construct_uri_starting_with_ipv4_like_glued) {
+ ASSERT_NO_THROW(network::uri("http://198.51.100.0example.com/"));
+}
+
+TEST(uri_test, construct_uri_like_short_ipv4) {
+ EXPECT_NO_THROW(network::uri("http://198.51.100/"));
+}
+
+TEST(uri_test, construct_uri_like_long_ipv4) {
+ EXPECT_NO_THROW(network::uri("http://198.51.100.0.255/"));
+}
+
+TEST(uri_test, make_uri_from_char_array) {
+ std::error_code ec;
+ network::uri uri = network::make_uri("http://www.example.com/", ec);
+ EXPECT_FALSE(ec);
+}
+
+TEST(uri_test, construct_uri_from_wchar_t_array) {
+ EXPECT_NO_THROW(network::uri(L"http://www.example.com/"));
+}
+
+TEST(uri_test, make_uri_from_wchar_t_array) {
+ std::error_code ec;
+ network::uri uri = network::make_uri(L"http://www.example.com/", ec);
+ EXPECT_FALSE(ec);
+}
+
+TEST(uri_test, construct_uri_from_string) {
+ EXPECT_NO_THROW(network::uri(std::string("http://www.example.com/")));
+}
+
+TEST(uri_test, make_uri_from_string) {
+ std::error_code ec;
+ network::uri uri = network::make_uri(std::string("http://www.example.com/"), ec);
+ EXPECT_FALSE(ec);
+}
+
+TEST(uri_test, construct_uri_from_wstring) {
+ EXPECT_NO_THROW(network::uri(std::wstring(L"http://www.example.com/")));
+}
+
+TEST(uri_test, make_uri_from_wstring) {
+ std::error_code ec;
+ network::uri uri = network::make_uri(std::wstring(L"http://www.example.com/"), ec);
+ EXPECT_FALSE(ec);
+}
+
+TEST(uri_test, basic_uri_scheme_test) {
+ network::uri instance("http://www.example.com/");
+ ASSERT_TRUE(instance.has_scheme());
+ EXPECT_EQ("http", instance.scheme());
+}
+
+TEST(uri_test, basic_uri_user_info_test) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_FALSE(instance.has_user_info());
+}
+
+TEST(uri_test, basic_uri_host_test) {
+ network::uri instance("http://www.example.com/");
+ ASSERT_TRUE(instance.has_host());
+ EXPECT_EQ("www.example.com", instance.host());
+}
+
+TEST(uri_test, basic_uri_port_test) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_FALSE(instance.has_port());
+}
+
+TEST(uri_test, basic_uri_path_test) {
+ network::uri instance("http://www.example.com/");
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, basic_uri_query_test) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_FALSE(instance.has_query());
+}
+
+TEST(uri_test, basic_uri_fragment_test) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_FALSE(instance.has_fragment());
+}
+
+TEST(uri_test, basic_uri_value_semantics_test) {
+ network::uri original;
+ network::uri assigned;
+ assigned = original;
+ EXPECT_EQ(original, assigned);
+ assigned = network::uri("http://www.example.com/");
+ EXPECT_NE(original, assigned);
+ network::uri copy(assigned);
+ EXPECT_EQ(copy, assigned);
+}
+
+TEST(uri_test, full_uri_scheme_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("http", instance.scheme());
+}
+
+TEST(uri_test, full_uri_user_info_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("user", instance.user_info());
+}
+
+TEST(uri_test, full_uri_host_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("www.example.com", instance.host());
+}
+
+TEST(uri_test, full_uri_port_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("80", instance.port());
+}
+
+TEST(uri_test, full_uri_port_as_int_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ(80, instance.port<int>());
+}
+
+TEST(uri_test, full_uri_path_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("/path", instance.path());
+}
+
+TEST(uri_test, full_uri_query_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, full_uri_fragment_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, full_uri_range_scheme_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_scheme());
+ EXPECT_EQ("http", instance.scheme());
+}
+
+TEST(uri_test, full_uri_range_user_info_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_user_info());
+ EXPECT_EQ("user", instance.user_info());
+}
+
+TEST(uri_test, full_uri_range_host_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_host());
+ EXPECT_EQ("www.example.com", instance.host());
+}
+
+TEST(uri_test, full_uri_range_port_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_port());
+ EXPECT_EQ("80", instance.port());
+}
+
+TEST(uri_test, full_uri_range_path_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("/path", instance.path());
+}
+
+TEST(uri_test, full_uri_range_query_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_query());
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, full_uri_range_fragment_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_fragment());
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, uri_with_empty_query) {
+ network::uri instance("http://example.com/?");
+ ASSERT_TRUE(instance.has_query());
+ EXPECT_EQ("", instance.query());
+}
+
+TEST(uri_test, mailto_test) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_EQ("mailto", instance.scheme());
+ EXPECT_EQ("john.doe@example.com", instance.path());
+}
+
+TEST(uri_test, file_test) {
+ network::uri instance("file:///bin/bash");
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("/bin/bash", instance.path());
+}
+
+TEST(uri_test, file_path_has_host_bug_98) {
+ network::uri instance("file:///bin/bash");
+ EXPECT_TRUE(instance.has_scheme());
+ EXPECT_FALSE(instance.has_user_info());
+ EXPECT_TRUE(instance.has_host());
+ EXPECT_FALSE(instance.has_port());
+ EXPECT_TRUE(instance.has_path());
+ EXPECT_FALSE(instance.has_query());
+ EXPECT_FALSE(instance.has_fragment());
+}
+
+TEST(uri_test, xmpp_test) {
+ network::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World");
+ EXPECT_EQ("xmpp", instance.scheme());
+ EXPECT_EQ("example-node@example.com", instance.path());
+ EXPECT_EQ("message;subject=Hello%20World", instance.query());
+}
+
+TEST(uri_test, ipv4_address_test) {
+ network::uri instance("http://129.79.245.252/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("129.79.245.252", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv4_loopback_test) {
+ network::uri instance("http://127.0.0.1/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("127.0.0.1", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_1) {
+ network::uri instance("http://[1080:0:0:0:8:800:200C:417A]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[1080:0:0:0:8:800:200C:417A]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_2) {
+ network::uri instance("http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:db8:85a3:8d3:1319:8a2e:370:7348]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_3) {
+ network::uri instance("http://[2001:db8:85a3:0:0:8a2e:370:7334]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:db8:85a3:0:0:8a2e:370:7334]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_4) {
+ network::uri instance("http://[2001:db8:85a3::8a2e:370:7334]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:db8:85a3::8a2e:370:7334]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_5) {
+ network::uri instance("http://[2001:0db8:0000:0000:0000:0000:1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:0db8:0000:0000:0000:0000:1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_6) {
+ network::uri instance("http://[2001:0db8:0000:0000:0000::1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:0db8:0000:0000:0000::1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_7) {
+ network::uri instance("http://[2001:0db8:0:0:0:0:1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:0db8:0:0:0:0:1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_8) {
+ network::uri instance("http://[2001:0db8:0:0::1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:0db8:0:0::1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_9) {
+ network::uri instance("http://[2001:0db8::1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:0db8::1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_10) {
+ network::uri instance("http://[2001:db8::1428:57ab]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[2001:db8::1428:57ab]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_11) {
+ network::uri instance("http://[::ffff:0c22:384e]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[::ffff:0c22:384e]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_12) {
+ network::uri instance("http://[fe80::]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[fe80::]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_address_test_13) {
+ network::uri instance("http://[::ffff:c000:280]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[::ffff:c000:280]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_loopback_test) {
+ network::uri instance("http://[::1]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[::1]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_loopback_test_1) {
+ network::uri instance("http://[0000:0000:0000:0000:0000:0000:0000:0001]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[0000:0000:0000:0000:0000:0000:0000:0001]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_v4inv6_test_1) {
+ network::uri instance("http://[::ffff:12.34.56.78]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[::ffff:12.34.56.78]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ipv6_v4inv6_test_2) {
+ network::uri instance("http://[::ffff:192.0.2.128]/");
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("[::ffff:192.0.2.128]", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, ftp_test) {
+ network::uri instance("ftp://john.doe@ftp.example.com/");
+ EXPECT_EQ("ftp", instance.scheme());
+ EXPECT_EQ("john.doe", instance.user_info());
+ EXPECT_EQ("ftp.example.com", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, news_test) {
+ network::uri instance("news:comp.infosystems.www.servers.unix");
+ EXPECT_EQ("news", instance.scheme());
+ EXPECT_EQ("comp.infosystems.www.servers.unix", instance.path());
+}
+
+TEST(uri_test, tel_test) {
+ network::uri instance("tel:+1-816-555-1212");
+ EXPECT_EQ("tel", instance.scheme());
+ EXPECT_EQ("+1-816-555-1212", instance.path());
+}
+
+TEST(uri_test, ldap_test) {
+ network::uri instance("ldap://[2001:db8::7]/c=GB?objectClass?one");
+ EXPECT_EQ("ldap", instance.scheme());
+ EXPECT_EQ("[2001:db8::7]", instance.host());
+ EXPECT_EQ("/c=GB", instance.path());
+ EXPECT_EQ("objectClass?one", instance.query());
+}
+
+TEST(uri_test, urn_test) {
+ network::uri instance("urn:oasis:names:specification:docbook:dtd:xml:4.1.2");
+ EXPECT_EQ("urn", instance.scheme());
+ EXPECT_EQ("oasis:names:specification:docbook:dtd:xml:4.1.2", instance.path());
+}
+
+TEST(uri_test, svn_ssh_test) {
+ network::uri instance("svn+ssh://example.com/");
+ EXPECT_EQ("svn+ssh", instance.scheme());
+ EXPECT_EQ("example.com", instance.host());
+ EXPECT_EQ("/", instance.path());
+}
+
+TEST(uri_test, copy_constructor_test) {
+ network::uri instance("http://www.example.com/");
+ network::uri copy = instance;
+ EXPECT_EQ(instance, copy);
+}
+
+TEST(uri_test, assignment_test) {
+ network::uri instance("http://www.example.com/");
+ network::uri copy;
+ copy = instance;
+ EXPECT_EQ(instance, copy);
+}
+
+TEST(uri_test, swap_test) {
+ network::uri original("http://example.com/path/to/file.txt");
+ network::uri instance("file:///something/different/");
+ original.swap(instance);
+
+ ASSERT_TRUE(original.has_scheme());
+ ASSERT_TRUE(original.has_host());
+ ASSERT_TRUE(original.has_path());
+ EXPECT_EQ("file", original.scheme());
+ EXPECT_EQ("", original.host());
+ EXPECT_EQ("/something/different/", original.path());
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_host());
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("example.com", instance.host());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+}
+
+TEST(uri_test, authority_test) {
+ network::uri instance("http://user@www.example.com:80/path?query#fragment");
+ ASSERT_TRUE(instance.has_authority());
+ EXPECT_EQ("user@www.example.com:80", instance.authority());
+}
+
+TEST(uri_test, partial_authority_test) {
+ network::uri instance("http://www.example.com/path?query#fragment");
+ ASSERT_TRUE(instance.has_authority());
+ EXPECT_EQ("www.example.com", instance.authority());
+}
+
+TEST(uri_test, range_test) {
+ const std::string url("http://www.example.com/");
+ network::uri instance(url);
+ EXPECT_TRUE(std::equal(std::begin(instance), std::end(instance),
+ std::begin(url)));
+}
+
+TEST(uri_test, issue_104_test) {
+ // https://github.com/cpp-netlib/cpp-netlib/issues/104
+ std::unique_ptr<network::uri> instance(new network::uri("http://www.example.com/"));
+ network::uri copy = *instance;
+ instance.reset();
+ EXPECT_EQ("http", copy.scheme());
+}
+
+TEST(uri_test, uri_set_test) {
+ std::set<network::uri> uri_set;
+ uri_set.insert(network::uri("http://www.example.com/"));
+ EXPECT_FALSE(uri_set.empty());
+ EXPECT_EQ(network::uri("http://www.example.com/"), (*std::begin(uri_set)));
+}
+
+TEST(uri_test, uri_unordered_set_test) {
+ std::unordered_set<network::uri> uri_set;
+ uri_set.insert(network::uri("http://www.example.com/"));
+ EXPECT_FALSE(uri_set.empty());
+ EXPECT_EQ(network::uri("http://www.example.com/"), (*std::begin(uri_set)));
+}
+
+TEST(uri_test, empty_uri) {
+ network::uri instance;
+ EXPECT_TRUE(instance.empty());
+}
+
+TEST(uri_test, empty_uri_has_no_scheme) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_scheme());
+}
+
+TEST(uri_test, empty_uri_has_no_user_info) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_user_info());
+}
+
+TEST(uri_test, empty_uri_has_no_host) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_host());
+}
+
+TEST(uri_test, empty_uri_has_no_port) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_port());
+}
+
+TEST(uri_test, empty_uri_has_no_path) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_path());
+}
+
+TEST(uri_test, empty_uri_has_no_query) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_query());
+}
+
+TEST(uri_test, empty_uri_has_no_fragment) {
+ network::uri instance;
+ EXPECT_FALSE(instance.has_fragment());
+}
+
+TEST(uri_test, http_is_absolute) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_TRUE(instance.is_absolute());
+}
+
+TEST(uri_test, mailto_has_no_user_info) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_FALSE(instance.has_user_info());
+}
+
+TEST(uri_test, mailto_has_no_host) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_FALSE(instance.has_host());
+}
+
+TEST(uri_test, mailto_has_no_port) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_FALSE(instance.has_port());
+}
+
+TEST(uri_test, mailto_has_no_authority) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_FALSE(instance.has_authority());
+}
+
+TEST(uri_test, http_is_not_opaque) {
+ network::uri instance("http://www.example.com/");
+ EXPECT_FALSE(instance.is_opaque());
+}
+
+TEST(uri_test, file_is_not_opaque) {
+ network::uri instance("file:///bin/bash");
+ EXPECT_FALSE(instance.is_opaque());
+}
+
+TEST(uri_test, mailto_is_absolute) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_TRUE(instance.is_absolute());
+}
+
+TEST(uri_test, mailto_is_opaque) {
+ network::uri instance("mailto:john.doe@example.com");
+ EXPECT_TRUE(instance.is_opaque());
+}
+
+TEST(uri_test, whitespace_no_throw) {
+ EXPECT_NO_THROW(network::uri(" http://www.example.com/ "));
+}
+
+TEST(uri_test, whitespace_is_trimmed) {
+ network::uri instance(" http://www.example.com/ ");
+ EXPECT_EQ("http://www.example.com/", instance);
+}
+
+TEST(uri_test, unnormalized_invalid_path_doesnt_throw) {
+ EXPECT_NO_THROW(network::uri("http://www.example.com/.."));
+}
+
+TEST(uri_test, unnormalized_invalid_path_is_valid) {
+ network::uri instance("http://www.example.com/..");
+ EXPECT_TRUE(instance.has_path());
+}
+
+TEST(uri_test, unnormalized_invalid_path_value) {
+ network::uri instance("http://www.example.com/..");
+ EXPECT_EQ("/..", instance.path());
+}
+
+TEST(uri_test, git) {
+ network::uri instance("git://github.com/cpp-netlib/cpp-netlib.git");
+ EXPECT_EQ("git", instance.scheme());
+ EXPECT_EQ("github.com", instance.host());
+ EXPECT_EQ("/cpp-netlib/cpp-netlib.git", instance.path());
+}
+
+TEST(uri_test, invalid_port_test) {
+ EXPECT_THROW(network::uri("http://123.34.23.56:6662626/"), network::uri_syntax_error);
+}
+
+TEST(uri_test, valid_empty_port_test) {
+ EXPECT_NO_THROW(network::uri("http://123.34.23.56:/"));
+}
+
+TEST(uri_test, empty_port_test) {
+ network::uri instance("http://123.34.23.56:/");
+ ASSERT_TRUE(instance.has_port());
+ EXPECT_EQ("", instance.port());
+}
+
+TEST(uri_test, full_copy_uri_scheme_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("http", instance.scheme());
+}
+
+TEST(uri_test, full_copy_uri_user_info_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("user", instance.user_info());
+}
+
+TEST(uri_test, full_copy_uri_host_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("www.example.com", instance.host());
+}
+
+TEST(uri_test, full_copy_uri_port_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("80", instance.port());
+}
+
+TEST(uri_test, full_copy_uri_path_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("/path", instance.path());
+}
+
+TEST(uri_test, full_copy_uri_query_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, full_copy_uri_fragment_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, full_move_uri_scheme_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("http", instance.scheme());
+}
+
+TEST(uri_test, full_move_uri_user_info_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("user", instance.user_info());
+}
+
+TEST(uri_test, full_move_uri_host_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("www.example.com", instance.host());
+}
+
+TEST(uri_test, full_move_uri_port_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("80", instance.port());
+}
+
+TEST(uri_test, full_move_uri_path_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("/path", instance.path());
+}
+
+TEST(uri_test, full_move_uri_query_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, full_move_uri_fragment_test) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, mailto_uri_path) {
+ network::uri origin("mailto:john.doe@example.com?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("john.doe@example.com", instance.path());
+}
+
+TEST(uri_test, mailto_uri_query) {
+ network::uri origin("mailto:john.doe@example.com?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, mailto_uri_fragment) {
+ network::uri origin("mailto:john.doe@example.com?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash) {
+ network::uri instance("scheme:/path/");
+ EXPECT_TRUE(instance.is_opaque());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_scheme) {
+ network::uri instance("scheme:/path/");
+ EXPECT_EQ("scheme", instance.scheme());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_path) {
+ network::uri instance("scheme:/path/");
+ EXPECT_EQ("/path/", instance.path());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_query) {
+ network::uri instance("scheme:/path/?query#fragment");
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_fragment) {
+ network::uri instance("scheme:/path/?query#fragment");
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_copy) {
+ network::uri origin("scheme:/path/");
+ network::uri instance = origin;
+ EXPECT_TRUE(instance.is_opaque());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_copy_query) {
+ network::uri origin("scheme:/path/?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("query", instance.query());
+}
+
+TEST(uri_test, opaque_uri_with_one_slash_copy_fragment) {
+ network::uri origin("scheme:/path/?query#fragment");
+ network::uri instance = origin;
+ EXPECT_EQ("fragment", instance.fragment());
+}
+
+TEST(uri_test, move_empty_uri_check_scheme) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_scheme());
+}
+
+TEST(uri_test, move_empty_uri_check_user_info) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_user_info());
+}
+
+TEST(uri_test, move_empty_uri_check_host) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_host());
+}
+
+TEST(uri_test, move_empty_uri_check_port) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_port());
+}
+
+TEST(uri_test, move_empty_uri_check_path) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_path());
+}
+
+TEST(uri_test, move_empty_uri_check_query) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_query());
+}
+
+TEST(uri_test, move_empty_uri_check_fragment) {
+ network::uri origin("http://user@www.example.com:80/path?query#fragment");
+ network::uri instance = std::move(origin);
+ EXPECT_FALSE(origin.has_fragment());
+}
+
+TEST(uri_test, DISABLED_empty_username_in_user_info) {
+ network::uri instance("ftp://:@localhost");
+ ASSERT_TRUE(instance.has_user_info());
+ EXPECT_EQ(":", instance.user_info());
+ EXPECT_EQ("localhost", instance.host());
+}
+
+TEST(uri_test, uri_begins_with_a_colon) {
+ EXPECT_THROW(network::uri("://example.com"), network::uri_syntax_error);
+}
+
+TEST(uri_test, uri_begins_with_a_number) {
+ EXPECT_THROW(network::uri("3http://example.com"), network::uri_syntax_error);
+}
+
+TEST(uri_test, uri_scheme_contains_an_invalid_character) {
+ EXPECT_THROW(network::uri("ht%tp://example.com"), network::uri_syntax_error);
+}
+
+TEST(uri_test, default_constructed_assignment_test) {
+ network::uri instance("http://www.example.com/");
+ instance = network::uri(); // <-- CRASHES HERE
+ EXPECT_TRUE(instance.empty());
+}
+
+TEST(uri_test, opaque_path_no_double_slash) {
+ network::uri instance("file:/path/to/something/");
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("/path/to/something/", instance.path());
+ EXPECT_TRUE(instance.is_opaque());
+}
+
+TEST(uri_test, non_opaque_path_has_double_slash) {
+ network::uri instance("file:///path/to/something/");
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("/path/to/something/", instance.path());
+ EXPECT_FALSE(instance.is_opaque());
+}
+
+TEST(uri_test, query_iterator_with_no_query) {
+ network::uri instance("http://example.com/");
+ ASSERT_FALSE(instance.has_query());
+ ASSERT_EQ(instance.query_begin(), instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_empty_query) {
+ network::uri instance("http://example.com/?");
+ ASSERT_TRUE(instance.has_query());
+ EXPECT_EQ("", instance.query());
+ EXPECT_EQ(instance.query_begin(), instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_single_kvp) {
+ network::uri instance("http://example.com/?a=b");
+ ASSERT_TRUE(instance.has_query());
+ auto query_it = instance.query_begin();
+ ASSERT_NE(query_it, instance.query_end());
+ EXPECT_EQ("a", query_it->first);
+ EXPECT_EQ("b", query_it->second);
+ ++query_it;
+ EXPECT_EQ(query_it, instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_two_kvps) {
+ network::uri instance("http://example.com/?a=b&c=d");
+
+ ASSERT_TRUE(instance.has_query());
+ auto query_it = instance.query_begin();
+ ASSERT_NE(query_it, instance.query_end());
+ EXPECT_EQ("a", query_it->first);
+ EXPECT_EQ("b", query_it->second);
+ ++query_it;
+ ASSERT_NE(query_it, instance.query_end());
+ EXPECT_EQ("c", query_it->first);
+ EXPECT_EQ("d", query_it->second);
+ ++query_it;
+ EXPECT_EQ(query_it, instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_two_kvps_using_semicolon_separator) {
+ network::uri instance("http://example.com/?a=b;c=d");
+
+ ASSERT_TRUE(instance.has_query());
+ auto query_it = instance.query_begin();
+ ASSERT_NE(query_it, instance.query_end());
+ EXPECT_EQ("a", query_it->first);
+ EXPECT_EQ("b", query_it->second);
+ ++query_it;
+ ASSERT_NE(query_it, instance.query_end());
+ EXPECT_EQ("c", query_it->first);
+ EXPECT_EQ("d", query_it->second);
+ ++query_it;
+ EXPECT_EQ(query_it, instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_key_and_no_value) {
+ network::uri instance("http://example.com/?query");
+ ASSERT_TRUE(instance.has_query());
+ auto query_it = instance.query_begin();
+ EXPECT_EQ("query", query_it->first);
+ EXPECT_EQ("", query_it->second);
+ ++query_it;
+ EXPECT_EQ(query_it, instance.query_end());
+}
+
+TEST(uri_test, query_iterator_with_fragment) {
+ network::uri instance("http://example.com/?a=b;c=d#fragment");
+ ASSERT_TRUE(instance.has_query());
+ ASSERT_NE(instance.query_begin(), instance.query_end());
+ auto query_it = instance.query_begin();
+ EXPECT_EQ("a", query_it->first);
+ EXPECT_EQ("b", query_it->second);
+ ++query_it;
+ EXPECT_EQ("c", query_it->first);
+ EXPECT_EQ("d", query_it->second);
+ ++query_it;
+ EXPECT_EQ(query_it, instance.query_end());
+}
+
+TEST(uri_test, copy_assignment_bug_98) {
+ network::uri original("file:///path/to/file.txt");
+
+ ASSERT_TRUE(original.has_scheme());
+ ASSERT_FALSE(original.is_opaque());
+ ASSERT_TRUE(original.has_host());
+ ASSERT_TRUE(original.has_path());
+
+ network::uri instance;
+ instance = original;
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_host());
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("", instance.host());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+}
+
+TEST(uri_test, copy_assignment_bug_98_2) {
+ network::uri original("file:///path/to/file.txt?query=value#foo");
+
+ network::uri instance;
+ instance = original;
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_TRUE(instance.has_query());
+ ASSERT_TRUE(instance.has_fragment());
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+ EXPECT_EQ("query=value", instance.query());
+ EXPECT_EQ("foo", instance.fragment());
+}
+
+TEST(uri_test, copy_constructor_bug_98) {
+ network::uri original("file:///path/to/file.txt?query=value#foo");
+
+ network::uri instance(original);
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_TRUE(instance.has_query());
+ ASSERT_TRUE(instance.has_fragment());
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+ EXPECT_EQ("query=value", instance.query());
+ EXPECT_EQ("foo", instance.fragment());
+}
+
+TEST(uri_test, move_assignment_bug_98) {
+ network::uri original("file:///path/to/file.txt?query=value#foo");
+
+ network::uri instance;
+ instance = std::move(original);
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_TRUE(instance.has_query());
+ ASSERT_TRUE(instance.has_fragment());
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+ EXPECT_EQ("query=value", instance.query());
+ EXPECT_EQ("foo", instance.fragment());
+}
+
+TEST(uri_test, move_constructor_bug_98) {
+ network::uri original("file:///path/to/file.txt?query=value#foo");
+
+ network::uri instance(std::move(original));
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_TRUE(instance.has_query());
+ ASSERT_TRUE(instance.has_fragment());
+ EXPECT_EQ("file", instance.scheme());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+ EXPECT_EQ("query=value", instance.query());
+ EXPECT_EQ("foo", instance.fragment());
+}
+
+TEST(uri_test, http_copy_assignment_bug_98) {
+ network::uri original("http://example.com/path/to/file.txt");
+
+ network::uri instance;
+ instance = original;
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_path());
+ EXPECT_EQ("http", instance.scheme());
+ EXPECT_EQ("/path/to/file.txt", instance.path());
+}
+
+TEST(uri_test, uri_has_host_bug_87) {
+ EXPECT_THROW(network::uri("http://"), network::uri_syntax_error);
+}
+
+TEST(uri_test, uri_has_host_bug_87_2) {
+ EXPECT_THROW(network::uri("http://user@"), network::uri_syntax_error);
+}
+
+TEST(uri_test, uri_has_host_bug_88) {
+ network::uri instance("http://user@host");
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_user_info());
+ ASSERT_TRUE(instance.has_host());
+ ASSERT_FALSE(instance.has_port());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_FALSE(instance.has_query());
+ ASSERT_FALSE(instance.has_fragment());
+
+ EXPECT_EQ("host", instance.host().to_string());
+}
+
+TEST(uri_test, uri_has_host_bug_88_2) {
+ network::uri instance("http://user@example.com");
+
+ ASSERT_TRUE(instance.has_scheme());
+ ASSERT_TRUE(instance.has_user_info());
+ ASSERT_TRUE(instance.has_host());
+ ASSERT_FALSE(instance.has_port());
+ ASSERT_TRUE(instance.has_path());
+ ASSERT_FALSE(instance.has_query());
+ ASSERT_FALSE(instance.has_fragment());
+
+ EXPECT_EQ("example.com", instance.host().to_string());
+}
+
+TEST(uri_test, assignment_operator_bug_116) {
+ network::uri a("http://a.com:1234");
+ ASSERT_TRUE(a.has_port());
+
+ const network::uri b("http://b.com");
+ ASSERT_FALSE(b.has_port());
+
+ a = b;
+ ASSERT_FALSE(a.has_port()) << a.string() << ", " << a.port();
+}
diff --git a/graphics/asymptote/LspCpp/third_party/uri/test/valid_urls.txt b/graphics/asymptote/LspCpp/third_party/uri/test/valid_urls.txt
new file mode 100644
index 0000000000..fab57f3e23
--- /dev/null
+++ b/graphics/asymptote/LspCpp/third_party/uri/test/valid_urls.txt
@@ -0,0 +1,36 @@
+http://foo.com/blah_blah
+http://foo.com/blah_blah/
+http://foo.com/blah_blah_(wikipedia)
+http://foo.com/blah_blah_(wikipedia)_(again)
+http://www.example.com/wpstyle/?p=364
+https://www.example.com/foo/?bar=baz&inga=42&quux
+http://✪df.ws/123
+http://userid:password@example.com:8080
+http://userid:password@example.com:8080/
+http://userid@example.com
+http://userid@example.com/
+http://userid@example.com:8080
+http://userid@example.com:8080/
+http://userid:password@example.com
+http://userid:password@example.com/
+http://142.42.1.1/
+http://142.42.1.1:8080/
+#http://➡.ws/䨹
+http://⌘.ws
+http://⌘.ws/
+http://foo.com/blah_(wikipedia)#cite-1
+http://foo.com/blah_(wikipedia)_blah#cite-1
+#http://foo.com/unicode_(✪)_in_parens
+http://foo.com/(something)?after=parens
+http://☺.damowmow.com/
+http://code.google.com/events/#&product=browser
+http://j.mp
+ftp://foo.bar/baz
+http://foo.bar/?q=Test%20URL-encoded%20stuff
+http://مثال.إختبار
+http://例子.测试
+http://उदाहरण.परीक्षा
+#http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com
+http://1337.net
+http://a.b-c.de
+http://223.255.255.254