]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.cc
Author: Francesco Chemolli <kinkie@squid-cache.org>
[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
17 TestStore::get
18 (const cache_key*)
19 {
20 return NULL;
21 }
22
23 void
24
25 TestStore::get
26 (String, void (*)(StoreEntry*, void*), void*)
27 {}
28
29 void
30
31 TestStore::init()
32 {}
33
34 size_t
35 TestStore::maxSize() const
36 {
37 return 3;
38 }
39
40 size_t
41 TestStore::minSize() const
42 {
43 return 1;
44 }
45
46 void
47 TestStore::stat(StoreEntry &) const
48 {
49 const_cast<TestStore *>(this)->statsCalled = true;
50 }
51
52 StoreSearch *
53 TestStore::search(String const url, HttpRequest *)
54 {
55 return NULL;
56 }
57
58 void
59 testStore::testSetRoot()
60 {
61 StorePointer aStore (new TestStore);
62 Store::Root(aStore);
63
64 CPPUNIT_ASSERT(&Store::Root() == aStore.getRaw());
65 Store::Root(NULL);
66 }
67
68 void
69 testStore::testUnsetRoot()
70 {
71 StorePointer aStore (new TestStore);
72 StorePointer aStore2 (new TestStore);
73 Store::Root(aStore);
74 Store::Root(aStore2);
75 CPPUNIT_ASSERT(&Store::Root() == aStore2.getRaw());
76 Store::Root(NULL);
77 }
78
79 void
80 testStore::testStats()
81 {
82 TestStorePointer aStore (new TestStore);
83 Store::Root(aStore.getRaw());
84 CPPUNIT_ASSERT(aStore->statsCalled == false);
85 Store::Stats(NullStoreEntry::getInstance());
86 CPPUNIT_ASSERT(aStore->statsCalled == true);
87 Store::Root(NULL);
88 }
89
90 void
91 testStore::testMaxSize()
92 {
93 StorePointer aStore (new TestStore);
94 Store::Root(aStore.getRaw());
95 CPPUNIT_ASSERT(aStore->maxSize() == 3);
96 Store::Root(NULL);
97 }