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