File: conversions_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 (53 lines) | stat: -rw-r--r-- 1,357 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
/***
 * Copyright (C) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 *
 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
 *
 * conversion_tests.cpp
 *
 * Tests to string functions and implicit conversions of the http::uri class.
 *
 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 ****/

#include "stdafx.h"

using namespace web;
using namespace utility;

namespace tests
{
namespace functional
{
namespace uri_tests
{
SUITE(conversions_tests)
{
    TEST(to_string_conversion)
    {
        utility::string_t encoded = uri::encode_uri(U("http://testname.com/%%?qstring"));
        uri u1(U("http://testname.com/%25%25?qstring"));

        VERIFY_ARE_EQUAL(uri::decode(encoded), uri::decode(u1.to_string()));
    }

    TEST(to_encoded_string)
    {
        utility::string_t encoded = uri::encode_uri(U("http://testname.com/%%?qstring"));
        uri u(U("http://testname.com/%25%25?qstring"));

        VERIFY_ARE_EQUAL(encoded, u.to_string());
    }

    TEST(empty_to_string)
    {
        uri u;
        VERIFY_ARE_EQUAL(U("/"), u.to_string());
    }

} // SUITE(conversions_tests)

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