Debian Codegraph @

LspCpp/third_party/uri/test/uri_comparison_test.cpp

raw
1 // Copyright (c) Glyn Matthews 2012-2016.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <gtest/gtest.h>
7 #include <network/uri.hpp>
8
9
10 TEST(uri_comparison_test, equality_test) {
11 network::uri lhs("http://www.example.com/");
12 network::uri rhs("http://www.example.com/");
13 ASSERT_EQ(lhs, rhs);
14 }
15
16 TEST(uri_comparison_test, equality_test_capitalized_scheme) {
17 network::uri lhs("http://www.example.com/");
18 network::uri rhs("HTTP://www.example.com/");
19 ASSERT_NE(lhs.compare(rhs, network::uri_comparison_level::string_comparison), 0);
20 }
21
22 TEST(uri_comparison_test, equality_test_capitalized_scheme_with_case_normalization) {
23 network::uri lhs("http://www.example.com/");
24 network::uri rhs("HTTP://www.example.com/");
25 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
26 }
27
28 TEST(uri_comparison_test, DISABLED_equality_test_capitalized_host) {
29 network::uri lhs("http://www.example.com/");
30 network::uri rhs("http://WWW.EXAMPLE.COM/");
31 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
32 }
33
34 TEST(uri_comparison_test, equality_test_with_single_dot_segment) {
35 network::uri lhs("http://www.example.com/./path");
36 network::uri rhs("http://www.example.com/path");
37 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
38 }
39
40 TEST(uri_comparison_test, equality_test_with_double_dot_segment) {
41 network::uri lhs("http://www.example.com/1/../2/");
42 network::uri rhs("http://www.example.com/2/");
43 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
44 }
45
46 TEST(uri_comparison_test, DISABLED_given_example_test) {
47 network::uri lhs("example://a/b/c/%7Bfoo%7D");
48 network::uri rhs("eXAMPLE://a/./b/../b/%63/%7bfoo%7d");
49 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
50 }
51
52 TEST(uri_comparison_test, equality_empty_lhs) {
53 network::uri lhs;
54 network::uri rhs("http://www.example.com/");
55 ASSERT_NE(lhs, rhs);
56 }
57
58 TEST(uri_comparison_test, equality_empty_rhs) {
59 network::uri lhs("http://www.example.com/");
60 network::uri rhs;
61 ASSERT_NE(lhs, rhs);
62 }
63
64 TEST(uri_comparison_test, inequality_test) {
65 network::uri lhs("http://www.example.com/");
66 network::uri rhs("http://www.example.com/");
67 ASSERT_FALSE(lhs != rhs);
68 }
69
70 TEST(uri_comparison_test, less_than_test) {
71 // lhs is lexicographically less than rhs
72 network::uri lhs("http://www.example.com/");
73 network::uri rhs("http://www.example.org/");
74 ASSERT_LT(lhs, rhs);
75 }
76
77 TEST(uri_comparison_test, percent_encoded_query_reserved_chars) {
78 network::uri lhs("http://www.example.com?foo=%5cbar");
79 network::uri rhs("http://www.example.com?foo=%5Cbar");
80 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
81 }
82
83
84 TEST(uri_comparison_test, percent_encoded_query_unreserved_chars) {
85 network::uri lhs("http://www.example.com?foo=%61%6c%70%68%61%31%32%33%2d%2e%5f%7e");
86 network::uri rhs("http://www.example.com?foo=alpha123-._~");
87 ASSERT_EQ(lhs.compare(rhs, network::uri_comparison_level::syntax_based), 0);
88 }