]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.cc
Removed squid-old.h
[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 TestStore::init()
27 {}
28
29 uint64_t
30 TestStore::maxSize() const
31 {
32 return 3;
33 }
34
35 uint64_t
36 TestStore::minSize() const
37 {
38 return 1;
39 }
40
41 uint64_t
42 TestStore::currentSize() const
43 {
44 return 2;
45 }
46
47 uint64_t
48 TestStore::currentCount() const
49 {
50 return 2;
51 }
52
53 int64_t
54 TestStore::maxObjectSize() const
55 {
56 return 1;
57 }
58
59 void
60 TestStore::getStats(StoreInfoStats &) const
61 {
62 }
63
64 void
65 TestStore::stat(StoreEntry &) const
66 {
67 const_cast<TestStore *>(this)->statsCalled = true;
68 }
69
70 StoreSearch *
71 TestStore::search(String const url, HttpRequest *)
72 {
73 return NULL;
74 }
75
76 void
77 testStore::testSetRoot()
78 {
79 StorePointer aStore(new TestStore);
80 Store::Root(aStore);
81
82 CPPUNIT_ASSERT(&Store::Root() == aStore.getRaw());
83 Store::Root(NULL);
84 }
85
86 void
87 testStore::testUnsetRoot()
88 {
89 StorePointer aStore(new TestStore);
90 StorePointer aStore2(new TestStore);
91 Store::Root(aStore);
92 Store::Root(aStore2);
93 CPPUNIT_ASSERT(&Store::Root() == aStore2.getRaw());
94 Store::Root(NULL);
95 }
96
97 void
98 testStore::testStats()
99 {
100 TestStorePointer aStore(new TestStore);
101 Store::Root(aStore.getRaw());
102 CPPUNIT_ASSERT(aStore->statsCalled == false);
103 Store::Stats(NullStoreEntry::getInstance());
104 CPPUNIT_ASSERT(aStore->statsCalled == true);
105 Store::Root(NULL);
106 }
107
108 void
109 testStore::testMaxSize()
110 {
111 StorePointer aStore(new TestStore);
112 Store::Root(aStore.getRaw());
113 CPPUNIT_ASSERT(aStore->maxSize() == 3);
114 Store::Root(NULL);
115 }