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