]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/testStore.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / tests / testStore.cc
CommitLineData
4e0938ef 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 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
582c2af2 9#include "squid.h"
c8f4eac4 10#include "Store.h"
602d9612 11#include "testStore.h"
7f861c77
AJ
12#include "unitTestMain.h"
13
c8f4eac4 14CPPUNIT_TEST_SUITE_REGISTRATION( testStore );
15
c8f4eac4 16int
17TestStore::callback()
18{
19 return 1;
20}
21
22StoreEntry*
6ca34f6f 23TestStore::get(const cache_key*)
c8f4eac4 24{
25 return NULL;
26}
27
28void
6ca34f6f 29TestStore::get(String, void (*)(StoreEntry*, void*), void*)
c8f4eac4 30{}
31
32void
c8f4eac4 33TestStore::init()
34{}
35
12e11a5c 36uint64_t
c8f4eac4 37TestStore::maxSize() const
38{
39 return 3;
40}
41
12e11a5c 42uint64_t
c8f4eac4 43TestStore::minSize() const
44{
45 return 1;
46}
47
d5d5493b
DK
48uint64_t
49TestStore::currentSize() const
50{
51 return 2;
52}
53
54uint64_t
55TestStore::currentCount() const
56{
57 return 2;
58}
59
60int64_t
61TestStore::maxObjectSize() const
62{
63 return 1;
64}
65
93bc1434
AR
66void
67TestStore::getStats(StoreInfoStats &) const
68{
69}
70
c8f4eac4 71void
72TestStore::stat(StoreEntry &) const
73{
74 const_cast<TestStore *>(this)->statsCalled = true;
75}
76
77StoreSearch *
2745fea5 78TestStore::search()
c8f4eac4 79{
80 return NULL;
81}
82
83void
84testStore::testSetRoot()
85{
2745fea5
AR
86 Store::Controller *aStore(new TestStore);
87 Store::Init(aStore);
c8f4eac4 88
2745fea5
AR
89 CPPUNIT_ASSERT_EQUAL(&Store::Root(), aStore);
90 Store::FreeMemory();
c8f4eac4 91}
92
93void
94testStore::testUnsetRoot()
95{
2745fea5
AR
96 Store::Controller *aStore(new TestStore);
97 Store::Controller *aStore2(new TestStore);
98 Store::Init(aStore);
99 Store::FreeMemory();
100 Store::Init(aStore2);
101 CPPUNIT_ASSERT_EQUAL(&Store::Root(),aStore2);
102 Store::FreeMemory();
c8f4eac4 103}
104
105void
106testStore::testStats()
107{
2745fea5
AR
108 TestStore *aStore(new TestStore);
109 Store::Init(aStore);
5d1dff27 110 CPPUNIT_ASSERT_EQUAL(false, aStore->statsCalled);
c8f4eac4 111 Store::Stats(NullStoreEntry::getInstance());
5d1dff27 112 CPPUNIT_ASSERT_EQUAL(true, aStore->statsCalled);
2745fea5 113 Store::FreeMemory();
c8f4eac4 114}
115
116void
117testStore::testMaxSize()
118{
2745fea5
AR
119 Store::Controller *aStore(new TestStore);
120 Store::Init(aStore);
5d1dff27 121 CPPUNIT_ASSERT_EQUAL(static_cast<uint64_t>(3), aStore->maxSize());
2745fea5 122 Store::FreeMemory();
c8f4eac4 123}
f53969cc 124