]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testURL.cc
Merge from trunk
[thirdparty/squid.git] / src / tests / testURL.cc
1 #define SQUID_UNIT_TEST 1
2 #include "config.h"
3
4 #include <cppunit/TestAssert.h>
5
6 #include "testURL.h"
7 #include "URL.h"
8 #include "Mem.h"
9
10 #if HAVE_SSTREAM
11 #include <sstream>
12 #endif
13
14 CPPUNIT_TEST_SUITE_REGISTRATION( testURL );
15
16 /* stub functions to link successfully */
17 void
18 shut_down(int)
19 {}
20
21 void
22 reconfigure(int)
23 {}
24
25 /* end stubs */
26
27 /* init memory pools */
28
29 void
30 testURL::setUp()
31 {
32 Mem::Init();
33 }
34
35 /*
36 * we can construct a URL with a URLScheme.
37 * This creates a URL for that scheme.
38 */
39 void
40 testURL::testConstructScheme()
41 {
42 URLScheme empty_scheme;
43 URL protoless_url(PROTO_NONE);
44 CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme());
45
46 URLScheme ftp_scheme(PROTO_FTP);
47 URL ftp_url(PROTO_FTP);
48 CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme());
49 }
50
51 /*
52 * a default constructed URL has scheme "NONE".
53 * Also, we should be able to use new and delete on
54 * scheme instances.
55 */
56 void
57 testURL::testDefaultConstructor()
58 {
59 URLScheme aScheme;
60 URL aUrl;
61 CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
62
63 URL *urlPointer = new URL;
64 CPPUNIT_ASSERT(urlPointer != NULL);
65 delete urlPointer;
66 }