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