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