]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / tests / testStore.h
1 /*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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
9 #ifndef SQUID_SRC_TEST_STORE_H
10 #define SQUID_SRC_TEST_STORE_H
11
12 #include "Store.h"
13 #include "store/Controlled.h"
14
15 #include "compat/cppunit.h"
16
17 /*
18 * test the store framework
19 */
20
21 class testStore : public CPPUNIT_NS::TestFixture
22 {
23 CPPUNIT_TEST_SUITE( testStore );
24 CPPUNIT_TEST( testSetRoot );
25 CPPUNIT_TEST( testUnsetRoot );
26 CPPUNIT_TEST( testStats );
27 CPPUNIT_TEST( testMaxSize );
28 CPPUNIT_TEST( testSwapMetaTypeClassification );
29 CPPUNIT_TEST_SUITE_END();
30
31 public:
32
33 protected:
34 void testSetRoot();
35 void testUnsetRoot();
36 void testStats();
37 void testMaxSize();
38 void testSwapMetaTypeClassification();
39 };
40
41 /// allows testing of methods without having all the other components live
42 class TestStore : public Store::Controller
43 {
44
45 public:
46 TestStore() : statsCalled (false) {}
47
48 bool statsCalled;
49
50 int callback() override;
51
52 virtual StoreEntry* get(const cache_key*);
53
54 virtual void get(String, void (*)(StoreEntry*, void*), void*);
55
56 void init() override;
57
58 void maintain() override {};
59
60 uint64_t maxSize() const override;
61
62 uint64_t minSize() const override;
63
64 uint64_t currentSize() const override;
65
66 uint64_t currentCount() const override;
67
68 int64_t maxObjectSize() const override;
69
70 void getStats(StoreInfoStats &) const override;
71
72 void stat(StoreEntry &) const override; /* output stats to the provided store entry */
73
74 virtual void reference(StoreEntry &) {} /* Reference this object */
75
76 virtual bool dereference(StoreEntry &) { return true; }
77
78 virtual StoreSearch *search();
79 };
80
81 typedef RefCount<TestStore> TestStorePointer;
82
83 #endif
84