2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_SRC_TEST_STORE_H
10 #define SQUID_SRC_TEST_STORE_H
13 #include "store/Controlled.h"
15 #include "compat/cppunit.h"
18 * test the store framework
21 class testStore
: public CPPUNIT_NS::TestFixture
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();
38 void testSwapMetaTypeClassification();
41 /// allows testing of methods without having all the other components live
42 class TestStore
: public Store::Controller
46 TestStore() : statsCalled (false) {}
50 int callback() override
;
52 virtual StoreEntry
* get(const cache_key
*);
54 virtual void get(String
, void (*)(StoreEntry
*, void*), void*);
58 void maintain() override
{};
60 uint64_t maxSize() const override
;
62 uint64_t minSize() const override
;
64 uint64_t currentSize() const override
;
66 uint64_t currentCount() const override
;
68 int64_t maxObjectSize() const override
;
70 void getStats(StoreInfoStats
&) const override
;
72 void stat(StoreEntry
&) const override
; /* output stats to the provided store entry */
74 virtual void reference(StoreEntry
&) {} /* Reference this object */
76 virtual bool dereference(StoreEntry
&) { return true; }
78 virtual StoreSearch
*search();
81 typedef RefCount
<TestStore
> TestStorePointer
;