]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testURL.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / tests / testURL.cc
1 /*
2 * Copyright (C) 1996-2015 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 "testURL.h"
14 #include "unitTestMain.h"
15 #include "URL.h"
16
17 #include <sstream>
18
19 CPPUNIT_TEST_SUITE_REGISTRATION( testURL );
20
21 /* init memory pools */
22
23 void
24 testURL::setUp()
25 {
26 Mem::Init();
27 }
28
29 /*
30 * we can construct a URL with a AnyP::UriScheme.
31 * This creates a URL for that scheme.
32 */
33 void
34 testURL::testConstructScheme()
35 {
36 AnyP::UriScheme empty_scheme;
37 URL protoless_url(AnyP::PROTO_NONE);
38 CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme());
39
40 AnyP::UriScheme ftp_scheme(AnyP::PROTO_FTP);
41 URL ftp_url(AnyP::PROTO_FTP);
42 CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme());
43 }
44
45 /*
46 * a default constructed URL has scheme "NONE".
47 * Also, we should be able to use new and delete on
48 * scheme instances.
49 */
50 void
51 testURL::testDefaultConstructor()
52 {
53 AnyP::UriScheme aScheme;
54 URL aUrl;
55 CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
56
57 URL *urlPointer = new URL;
58 CPPUNIT_ASSERT(urlPointer != NULL);
59 delete urlPointer;
60 }
61