]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.cc
Boilerplate: copyright blurb updates for test-suite
[thirdparty/squid.git] / src / tests / testStore.cc
1 /*
2 * Copyright (C) 1996-2014 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 "Store.h"
11 #include "testStore.h"
12
13 CPPUNIT_TEST_SUITE_REGISTRATION( testStore );
14
15 int
16 TestStore::callback()
17 {
18 return 1;
19 }
20
21 StoreEntry*
22 TestStore::get(const cache_key*)
23 {
24 return NULL;
25 }
26
27 void
28 TestStore::get(String, void (*)(StoreEntry*, void*), void*)
29 {}
30
31 void
32 TestStore::init()
33 {}
34
35 uint64_t
36 TestStore::maxSize() const
37 {
38 return 3;
39 }
40
41 uint64_t
42 TestStore::minSize() const
43 {
44 return 1;
45 }
46
47 uint64_t
48 TestStore::currentSize() const
49 {
50 return 2;
51 }
52
53 uint64_t
54 TestStore::currentCount() const
55 {
56 return 2;
57 }
58
59 int64_t
60 TestStore::maxObjectSize() const
61 {
62 return 1;
63 }
64
65 void
66 TestStore::getStats(StoreInfoStats &) const
67 {
68 }
69
70 void
71 TestStore::stat(StoreEntry &) const
72 {
73 const_cast<TestStore *>(this)->statsCalled = true;
74 }
75
76 StoreSearch *
77 TestStore::search(String const url, HttpRequest *)
78 {
79 return NULL;
80 }
81
82 void
83 testStore::testSetRoot()
84 {
85 StorePointer aStore(new TestStore);
86 Store::Root(aStore);
87
88 CPPUNIT_ASSERT_EQUAL(&Store::Root(),aStore.getRaw());
89 Store::Root(NULL);
90 }
91
92 void
93 testStore::testUnsetRoot()
94 {
95 StorePointer aStore(new TestStore);
96 StorePointer aStore2(new TestStore);
97 Store::Root(aStore);
98 Store::Root(aStore2);
99 CPPUNIT_ASSERT_EQUAL(&Store::Root(),aStore2.getRaw());
100 Store::Root(NULL);
101 }
102
103 void
104 testStore::testStats()
105 {
106 TestStorePointer aStore(new TestStore);
107 Store::Root(aStore.getRaw());
108 CPPUNIT_ASSERT_EQUAL(false, aStore->statsCalled);
109 Store::Stats(NullStoreEntry::getInstance());
110 CPPUNIT_ASSERT_EQUAL(true, aStore->statsCalled);
111 Store::Root(NULL);
112 }
113
114 void
115 testStore::testMaxSize()
116 {
117 StorePointer aStore(new TestStore);
118 Store::Root(aStore.getRaw());
119 CPPUNIT_ASSERT_EQUAL(static_cast<uint64_t>(3), aStore->maxSize());
120 Store::Root(NULL);
121 }