]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testURL.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / tests / testURL.cc
1 /*
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10
11 #include <cppunit/TestAssert.h>
12
13 #include "anyp/Uri.h"
14 #include "Debug.h"
15 #include "tests/testURL.h"
16 #include "unitTestMain.h"
17
18 #include <sstream>
19
20 CPPUNIT_TEST_SUITE_REGISTRATION( testURL );
21
22 /* init memory pools */
23
24 void
25 testURL::setUp()
26 {
27 Mem::Init();
28 AnyP::UriScheme::Init();
29 }
30
31 /*
32 * we can construct a URL with a AnyP::UriScheme.
33 * This creates a URL for that scheme.
34 */
35 void
36 testURL::testConstructScheme()
37 {
38 AnyP::UriScheme empty_scheme;
39 AnyP::Uri protoless_url(AnyP::PROTO_NONE);
40 CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme());
41
42 AnyP::UriScheme ftp_scheme(AnyP::PROTO_FTP);
43 AnyP::Uri ftp_url(AnyP::PROTO_FTP);
44 CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme());
45 }
46
47 /*
48 * a default constructed URL has scheme "NONE".
49 * Also, we should be able to use new and delete on
50 * scheme instances.
51 */
52 void
53 testURL::testDefaultConstructor()
54 {
55 AnyP::UriScheme aScheme;
56 AnyP::Uri aUrl;
57 CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
58
59 auto *urlPointer = new AnyP::Uri;
60 CPPUNIT_ASSERT(urlPointer != NULL);
61 delete urlPointer;
62 }
63