]>
Commit | Line | Data |
---|---|---|
4e0938ef | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
4e0938ef AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
582c2af2 | 9 | #include "squid.h" |
c8f4eac4 | 10 | #include "Store.h" |
602d9612 | 11 | #include "testStore.h" |
7f861c77 AJ |
12 | #include "unitTestMain.h" |
13 | ||
c8f4eac4 | 14 | CPPUNIT_TEST_SUITE_REGISTRATION( testStore ); |
15 | ||
c8f4eac4 | 16 | int |
17 | TestStore::callback() | |
18 | { | |
19 | return 1; | |
20 | } | |
21 | ||
22 | StoreEntry* | |
6ca34f6f | 23 | TestStore::get(const cache_key*) |
c8f4eac4 | 24 | { |
25 | return NULL; | |
26 | } | |
27 | ||
28 | void | |
6ca34f6f | 29 | TestStore::get(String, void (*)(StoreEntry*, void*), void*) |
c8f4eac4 | 30 | {} |
31 | ||
32 | void | |
c8f4eac4 | 33 | TestStore::init() |
34 | {} | |
35 | ||
12e11a5c | 36 | uint64_t |
c8f4eac4 | 37 | TestStore::maxSize() const |
38 | { | |
39 | return 3; | |
40 | } | |
41 | ||
12e11a5c | 42 | uint64_t |
c8f4eac4 | 43 | TestStore::minSize() const |
44 | { | |
45 | return 1; | |
46 | } | |
47 | ||
d5d5493b DK |
48 | uint64_t |
49 | TestStore::currentSize() const | |
50 | { | |
51 | return 2; | |
52 | } | |
53 | ||
54 | uint64_t | |
55 | TestStore::currentCount() const | |
56 | { | |
57 | return 2; | |
58 | } | |
59 | ||
60 | int64_t | |
61 | TestStore::maxObjectSize() const | |
62 | { | |
63 | return 1; | |
64 | } | |
65 | ||
93bc1434 AR |
66 | void |
67 | TestStore::getStats(StoreInfoStats &) const | |
68 | { | |
69 | } | |
70 | ||
c8f4eac4 | 71 | void |
72 | TestStore::stat(StoreEntry &) const | |
73 | { | |
74 | const_cast<TestStore *>(this)->statsCalled = true; | |
75 | } | |
76 | ||
77 | StoreSearch * | |
2745fea5 | 78 | TestStore::search() |
c8f4eac4 | 79 | { |
80 | return NULL; | |
81 | } | |
82 | ||
83 | void | |
84 | testStore::testSetRoot() | |
85 | { | |
2745fea5 AR |
86 | Store::Controller *aStore(new TestStore); |
87 | Store::Init(aStore); | |
c8f4eac4 | 88 | |
2745fea5 AR |
89 | CPPUNIT_ASSERT_EQUAL(&Store::Root(), aStore); |
90 | Store::FreeMemory(); | |
c8f4eac4 | 91 | } |
92 | ||
93 | void | |
94 | testStore::testUnsetRoot() | |
95 | { | |
2745fea5 AR |
96 | Store::Controller *aStore(new TestStore); |
97 | Store::Controller *aStore2(new TestStore); | |
98 | Store::Init(aStore); | |
99 | Store::FreeMemory(); | |
100 | Store::Init(aStore2); | |
101 | CPPUNIT_ASSERT_EQUAL(&Store::Root(),aStore2); | |
102 | Store::FreeMemory(); | |
c8f4eac4 | 103 | } |
104 | ||
105 | void | |
106 | testStore::testStats() | |
107 | { | |
2745fea5 AR |
108 | TestStore *aStore(new TestStore); |
109 | Store::Init(aStore); | |
5d1dff27 | 110 | CPPUNIT_ASSERT_EQUAL(false, aStore->statsCalled); |
c8f4eac4 | 111 | Store::Stats(NullStoreEntry::getInstance()); |
5d1dff27 | 112 | CPPUNIT_ASSERT_EQUAL(true, aStore->statsCalled); |
2745fea5 | 113 | Store::FreeMemory(); |
c8f4eac4 | 114 | } |
115 | ||
116 | void | |
117 | testStore::testMaxSize() | |
118 | { | |
2745fea5 AR |
119 | Store::Controller *aStore(new TestStore); |
120 | Store::Init(aStore); | |
5d1dff27 | 121 | CPPUNIT_ASSERT_EQUAL(static_cast<uint64_t>(3), aStore->maxSize()); |
2745fea5 | 122 | Store::FreeMemory(); |
c8f4eac4 | 123 | } |
f53969cc | 124 |