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