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