squid-
cache.org
Optimising Web Delivery
Docs
Download
Donate
Support
About
Contact
Shop
Blog
src
tests
testLookupTable.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/LookupTable.h
"
11
#include "
testLookupTable.h
"
12
#include "
unitTestMain.h
"
13
14
CPPUNIT_TEST_SUITE_REGISTRATION
(
testLookupTable
);
15
16
enum
EnumData
{
17
ENUM_1
,
18
ENUM_2
,
19
ENUM_3
,
20
ENUM_4
,
21
ENUM_5
,
22
ENUM_6
,
23
ENUM_7
,
24
ENUM_INVALID
25
};
26
27
static
const
LookupTable<EnumData>::Record
tableData
[] = {
28
{
"one"
,
ENUM_1
},
29
{
"two"
,
ENUM_2
},
30
{
"three"
,
ENUM_3
},
31
{
"four"
,
ENUM_4
},
32
{
"five"
,
ENUM_5
},
33
{
"six"
,
ENUM_6
},
34
{
"seven"
,
ENUM_7
},
35
{
nullptr
,
ENUM_INVALID
}
36
};
37
38
void
39
testLookupTable::testLookupTableLookup
()
40
{
41
LookupTable<EnumData>
lt(
ENUM_INVALID
,
tableData
);
42
// element found
43
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"one"
)),
ENUM_1
);
44
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"two"
)),
ENUM_2
);
45
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"three"
)),
ENUM_3
);
46
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"four"
)),
ENUM_4
);
47
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"five"
)),
ENUM_5
);
48
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"six"
)),
ENUM_6
);
49
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"seven"
)),
ENUM_7
);
50
51
// element not found
52
CPPUNIT_ASSERT_EQUAL(lt.
lookup
(
SBuf
(
"eleventy"
)),
ENUM_INVALID
);
53
}
54
ENUM_3
@ ENUM_3
Definition:
testLookupTable.cc:19
ENUM_2
@ ENUM_2
Definition:
testLookupTable.cc:18
ENUM_5
@ ENUM_5
Definition:
testLookupTable.cc:21
ENUM_7
@ ENUM_7
Definition:
testLookupTable.cc:23
SBuf
Definition:
SBuf.h:87
ENUM_6
@ ENUM_6
Definition:
testLookupTable.cc:22
unitTestMain.h
LookupTableRecord
Definition:
LookupTable.h:28
LookupTable::lookup
EnumType lookup(const SBuf &key) const
Definition:
LookupTable.h:65
CPPUNIT_TEST_SUITE_REGISTRATION
CPPUNIT_TEST_SUITE_REGISTRATION(testLookupTable)
ENUM_1
@ ENUM_1
Definition:
testLookupTable.cc:17
LookupTable.h
EnumData
EnumData
Definition:
testLookupTable.cc:16
testLookupTable
Definition:
testLookupTable.h:15
testLookupTable::testLookupTableLookup
void testLookupTableLookup()
Definition:
testLookupTable.cc:39
ENUM_INVALID
@ ENUM_INVALID
Definition:
testLookupTable.cc:24
testLookupTable.h
ENUM_4
@ ENUM_4
Definition:
testLookupTable.cc:20
squid.h
LookupTable
Definition:
LookupTable.h:52
tableData
static const LookupTable< EnumData >::Record tableData[]
Definition:
testLookupTable.cc:27
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