summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/LspCpp/third_party/uri/test/uri_comparison_test.cpp
blob: 67ca4363d05d25d69f1a17e3ace9fd99c01c3f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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);
}