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
15
25};
26
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
38void
40{
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
EnumType lookup(const SBuf &key) const
Definition: LookupTable.h:65
Definition: SBuf.h:94
void testLookupTableLookup()
CPPUNIT_TEST_SUITE_REGISTRATION(testLookupTable)
EnumData
@ ENUM_2
@ ENUM_7
@ ENUM_3
@ ENUM_5
@ ENUM_6
@ ENUM_INVALID
@ ENUM_1
@ ENUM_4
static const LookupTable< EnumData >::Record tableData[]

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors