]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testCacheManager.cc
Merged from trunk.
[thirdparty/squid.git] / src / tests / testCacheManager.cc
1 #define SQUID_UNIT_TEST 1
2
3 #include "squid.h"
4 #include <cppunit/TestAssert.h>
5
6 #include "Mem.h"
7 #include "testCacheManager.h"
8 #include "CacheManager.h"
9 #include "Store.h"
10
11
12 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager );
13
14 /* stub functions to link successfully */
15 void
16 shut_down(int)
17 {}
18
19 void
20 reconfigure(int)
21 {}
22
23 /* end stubs */
24
25 /* init memory pools */
26
27 void testCacheManager::setUp()
28 {
29 Mem::Init();
30 }
31
32 /*
33 * Test creating a CacheManager
34 */
35 void
36 testCacheManager::testCreate()
37 {
38 CacheManager::GetInstance(); //it's a singleton..
39 }
40
41 /* an action to register */
42 static void
43 dummy_action(StoreEntry * sentry)
44 {
45 sentry->flags=1;
46 }
47
48 /*
49 * registering an action makes it findable.
50 */
51 void
52 testCacheManager::testRegister()
53 {
54 CacheManager *manager=CacheManager::GetInstance();
55
56 manager->registerAction("sample", "my sample", &dummy_action, false, false);
57 CacheManagerAction *anAction = manager->findAction("sample");
58
59 CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.pw_req);
60 CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.atomic);
61 CPPUNIT_ASSERT_EQUAL(String("sample"), String(anAction->action));
62
63 StoreEntry *sentry=new StoreEntry();
64 sentry->flags=0x25; //arbitrary test value
65 anAction->run(sentry);
66 CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags);
67 }