testURL.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 "anyp/Uri.h"
12#include "compat/cppunit.h"
13#include "debug/Stream.h"
14#include "unitTestMain.h"
15
16#include <cppunit/TestAssert.h>
17#include <sstream>
18
19/*
20 * test the Anyp::Uri-related classes
21 */
22
23class TestUri : public CPPUNIT_NS::TestFixture
24{
29
30protected:
33};
35
37class MyTestProgram: public TestProgram
38{
39public:
40 /* TestProgram API */
41 void startup() override;
42};
43
44void
46{
47 Mem::Init();
49}
50
51/*
52 * we can construct a URL with a AnyP::UriScheme.
53 * This creates a URL for that scheme.
54 */
55void
57{
58 AnyP::UriScheme empty_scheme;
59 AnyP::Uri protoless_url(AnyP::PROTO_NONE);
60 CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme());
61
64 CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme());
65}
66
67/*
68 * a default constructed URL has scheme "NONE".
69 * Also, we should be able to use new and delete on
70 * scheme instances.
71 */
72void
74{
75 AnyP::UriScheme aScheme;
76 AnyP::Uri aUrl;
77 CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
78
79 auto *urlPointer = new AnyP::Uri;
80 CPPUNIT_ASSERT(urlPointer != nullptr);
81 delete urlPointer;
82}
83
84int
85main(int argc, char *argv[])
86{
87 return MyTestProgram().run(argc, argv);
88}
89
static void Init()
initializes down-cased protocol scheme names array
Definition: UriScheme.cc:38
Definition: Uri.h:31
AnyP::UriScheme const & getScheme() const
Definition: Uri.h:67
customizes our test setup
void startup() override
implements test program's main() function while enabling customization
Definition: unitTestMain.h:26
int run(int argc, char *argv[])
Definition: unitTestMain.h:44
void testDefaultConstructor()
Definition: testURL.cc:73
CPPUNIT_TEST_SUITE_END()
void testConstructScheme()
Definition: testURL.cc:56
CPPUNIT_TEST(testDefaultConstructor)
CPPUNIT_TEST_SUITE(TestUri)
CPPUNIT_TEST(testConstructScheme)
@ PROTO_NONE
Definition: ProtocolType.h:24
@ PROTO_FTP
Definition: ProtocolType.h:26
void Init()
Definition: old_api.cc:425
int main(int argc, char *argv[])
Definition: testURL.cc:85
CPPUNIT_TEST_SUITE_REGISTRATION(TestUri)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors