squid-
cache.org
Optimising Web Delivery
Docs
Download
Donate
Support
About
Contact
Shop
Blog
src
tests
testYesNoNone.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2022 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
#include "
base/YesNoNone.h
"
11
#include "
tests/testYesNoNone.h
"
12
#include "
unitTestMain.h
"
13
14
#include <stdexcept>
15
16
CPPUNIT_TEST_SUITE_REGISTRATION
(
testYesNoNone
);
17
18
void
19
testYesNoNone::testBasics
()
20
{
21
// unconfigured, non-implicit
22
{
23
YesNoNone
v;
24
CPPUNIT_ASSERT_EQUAL(
false
, v.
configured
());
25
// cannot test the value it is 'undefined' and will assert
26
}
27
// implicit dtor test
28
29
// unconfigured, implicit true
30
{
31
YesNoNone
v(
true
);
32
CPPUNIT_ASSERT_EQUAL(
false
, v.
configured
());
33
CPPUNIT_ASSERT(v);
34
CPPUNIT_ASSERT_EQUAL(
true
,
static_cast<
bool
>
(v));
35
36
// check explicit setter method
37
v.
configure
(
false
);
38
CPPUNIT_ASSERT_EQUAL(
true
, v.
configured
());
39
CPPUNIT_ASSERT(!v);
40
CPPUNIT_ASSERT_EQUAL(
false
,
static_cast<
bool
>
(v));
41
}
42
43
// unconfigured, implicit false
44
{
45
YesNoNone
v(
false
);
46
CPPUNIT_ASSERT_EQUAL(
false
, v.
configured
());
47
CPPUNIT_ASSERT(!v);
48
CPPUNIT_ASSERT_EQUAL(
false
,
static_cast<
bool
>
(v));
49
50
// check assignment operator
51
v =
YesNoNone
(
true
);
52
CPPUNIT_ASSERT_EQUAL(
false
, v.
configured
());
53
CPPUNIT_ASSERT(v);
54
CPPUNIT_ASSERT_EQUAL(
true
,
static_cast<
bool
>
(v));
55
}
56
}
57
CPPUNIT_TEST_SUITE_REGISTRATION
CPPUNIT_TEST_SUITE_REGISTRATION(testYesNoNone)
YesNoNone.h
testYesNoNone::testBasics
void testBasics()
Definition:
testYesNoNone.cc:19
unitTestMain.h
YesNoNone::configure
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition:
YesNoNone.h:53
testYesNoNone
Definition:
testYesNoNone.h:20
YesNoNone::configured
bool configured() const
Definition:
YesNoNone.h:67
YesNoNone
Definition:
YesNoNone.h:29
squid.h
testYesNoNone.h
Introduction
About Squid
Why Squid?
Squid Developers
How to Donate
How to Help Out
Getting Squid
Squid Source Packages
Squid Deployment Case-Studies
Squid Software Foundation
Documentation
Configuration:
Reference
Examples
FAQ
and
Wiki
Guide Books:
Beginners
Definitive
Non-English
More...
Support
Security Advisories
Bugzilla Database
Mailing lists
Contacting us
Commercial services
Project Sponsors
Squid-based products
Miscellaneous
Developer Resources
Related Writings
Related Software:
Authenticators
Ecap
Icap
Ident
Log Analysis
Monitor
Proxies
Redirectors
General
Squid Artwork
Web Site Translations
Japanese
Mirrors
Website:
gr
il
jp
pl
...
full list
FTP Package Archive