File: operator_tests.cpp

package info (click to toggle)
cpprest 2.10.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,916 kB
  • sloc: cpp: 71,086; sh: 275; makefile: 170; javascript: 147
file content (80 lines) | stat: -rw-r--r-- 2,607 bytes parent folder | download | duplicates (3)
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
/***
 * Copyright (C) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 *
 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
 *
 * operator_tests.cpp
 *
 * Tests for operators of the uri class.
 *
 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 ****/

#include "stdafx.h"

using namespace web;
using namespace utility;

namespace tests
{
namespace functional
{
namespace uri_tests
{
SUITE(operator_tests)
{
    TEST(uri_basic_equality)
    {
        VERIFY_ARE_EQUAL(uri(U("")), uri(U("")));

        uri u1(U("http://localhost:80/path1"));
        uri u2(U("http://localhost:80/path1"));
        VERIFY_ARE_EQUAL(u1, u2);
    }

    TEST(uri_decoded_equality)
    {
        uri_builder u3b(U("http://localhost:80"));
        u3b.set_path(U("path 1"), true);

        uri u3 = u3b.to_uri();
        uri u4(U("http://localhost:80/path%201"));
        VERIFY_ARE_EQUAL(u3, u4);

        uri u5(U("http://localhost:80/pat%68a1"));
        uri u6(U("http://localhost:80/patha1"));
        VERIFY_ARE_EQUAL(u5, u6);

        uri u9(U("http://localhost:80/patha1?name=first#t%65st"));
        uri u10(U("http://localhost:80/patha1?name=first#test"));
        VERIFY_ARE_EQUAL(u9, u10);
    }

    TEST(uri_basic_inequality)
    {
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1")), uri(U("https://localhost:80/path1")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1")), uri(U("http://localhost2:80/path1")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1")), uri(U("http://localhost:81/path1")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1")), uri(U("http://localhost:80/path2")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1?key=value")),
                             uri(U("http://localhost:80/path1?key=value2")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://localhost:80/path1?key=value#nose")),
                             uri(U("http://localhost:80/path1?key=value#nose1")));
    }

    TEST(test_empty)
    {
        VERIFY_ARE_EQUAL(uri(), uri());
        VERIFY_ARE_EQUAL(uri(U("htTp://Path")), uri(U("hTtp://pAth")));

        VERIFY_ARE_NOT_EQUAL(uri(U("http://path")), uri());
        VERIFY_ARE_NOT_EQUAL(uri(), uri(U("http://path")));
        VERIFY_ARE_NOT_EQUAL(uri(U("http://path1")), uri(U("http://path2")));
    }

} // SUITE(operator_tests)

} // namespace uri_tests
} // namespace functional
} // namespace tests