]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.cc
Merged from parent (trunk r11240, circa 3.2.0.5+)
[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 void
43 TestStore::stat(StoreEntry &) const
44 {
45 const_cast<TestStore *>(this)->statsCalled = true;
46 }
47
48 StoreSearch *
49 TestStore::search(String const url, HttpRequest *)
50 {
51 return NULL;
52 }
53
54 void
55 testStore::testSetRoot()
56 {
57 StorePointer aStore(new TestStore);
58 Store::Root(aStore);
59
60 CPPUNIT_ASSERT(&Store::Root() == aStore.getRaw());
61 Store::Root(NULL);
62 }
63
64 void
65 testStore::testUnsetRoot()
66 {
67 StorePointer aStore(new TestStore);
68 StorePointer aStore2(new TestStore);
69 Store::Root(aStore);
70 Store::Root(aStore2);
71 CPPUNIT_ASSERT(&Store::Root() == aStore2.getRaw());
72 Store::Root(NULL);
73 }
74
75 void
76 testStore::testStats()
77 {
78 TestStorePointer aStore(new TestStore);
79 Store::Root(aStore.getRaw());
80 CPPUNIT_ASSERT(aStore->statsCalled == false);
81 Store::Stats(NullStoreEntry::getInstance());
82 CPPUNIT_ASSERT(aStore->statsCalled == true);
83 Store::Root(NULL);
84 }
85
86 void
87 testStore::testMaxSize()
88 {
89 StorePointer aStore(new TestStore);
90 Store::Root(aStore.getRaw());
91 CPPUNIT_ASSERT(aStore->maxSize() == 3);
92 Store::Root(NULL);
93 }