]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/testURL.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / tests / testURL.cc
CommitLineData
4e0938ef 1/*
f70aedc4 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
4e0938ef
AJ
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
f7f3304a 9#include "squid.h"
e1f7507e 10
985c86bc 11#include <cppunit/TestAssert.h>
12
c8ab5ec6 13#include "anyp/Uri.h"
5c51bffb 14#include "Debug.h"
c8ab5ec6 15#include "tests/testURL.h"
7f861c77 16#include "unitTestMain.h"
985c86bc 17
27e059d4 18#include <sstream>
27e059d4 19
985c86bc 20CPPUNIT_TEST_SUITE_REGISTRATION( testURL );
21
985c86bc 22/* init memory pools */
23
16555581 24void
25testURL::setUp()
985c86bc 26{
16555581 27 Mem::Init();
50a43a49 28 AnyP::UriScheme::Init();
16555581 29}
985c86bc 30
31/*
1ca54a54 32 * we can construct a URL with a AnyP::UriScheme.
985c86bc 33 * This creates a URL for that scheme.
34 */
35void
36testURL::testConstructScheme()
37{
1ca54a54 38 AnyP::UriScheme empty_scheme;
c8ab5ec6 39 AnyP::Uri protoless_url(AnyP::PROTO_NONE);
41030a36 40 CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme());
41
1ca54a54 42 AnyP::UriScheme ftp_scheme(AnyP::PROTO_FTP);
c8ab5ec6 43 AnyP::Uri ftp_url(AnyP::PROTO_FTP);
41030a36 44 CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme());
985c86bc 45}
46
47/*
48 * a default constructed URL has scheme "NONE".
49 * Also, we should be able to use new and delete on
50 * scheme instances.
51 */
52void
53testURL::testDefaultConstructor()
54{
1ca54a54 55 AnyP::UriScheme aScheme;
c8ab5ec6 56 AnyP::Uri aUrl;
41030a36 57 CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
985c86bc 58
c8ab5ec6 59 auto *urlPointer = new AnyP::Uri;
985c86bc 60 CPPUNIT_ASSERT(urlPointer != NULL);
61 delete urlPointer;
62}
f53969cc 63