~ubuntu-branches/ubuntu/quantal/poco/quantal

« back to all changes in this revision

Viewing changes to Foundation/testsuite/src/UniqueExpireLRUCacheTest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2008-11-15 11:39:15 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081115113915-7kauhm2c3m2i7oid
Tags: 1.3.3p1-2
* Fixed FTBFS with GCC 4.4 due to missing #include (Closes: #505619)
* Renamed 20_gcc43-missing-include.dpatch to 20_gcc44-missing-include.dpatch
* Downgraded dependencies on -dbg packages (Closes: #504342)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// UniqueExpireLRUCacheTest.cpp
3
3
//
4
 
// $Id: //poco/1.3/Foundation/testsuite/src/UniqueExpireLRUCacheTest.cpp#1 $
 
4
// $Id: //poco/1.3/Foundation/testsuite/src/UniqueExpireLRUCacheTest.cpp#2 $
5
5
//
6
6
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
7
7
// and Contributors.
35
35
#include "CppUnit/TestSuite.h"
36
36
#include "Poco/Exception.h"
37
37
#include "Poco/UniqueExpireLRUCache.h"
 
38
#include "Poco/UniqueAccessExpireLRUCache.h"
 
39
#include "Poco/AccessExpirationDecorator.h"
38
40
#include "Poco/Bugcheck.h"
39
41
#include "Poco/Thread.h"
40
42
 
57
59
        }
58
60
};
59
61
 
 
62
 
 
63
typedef AccessExpirationDecorator<int> DIntVal;
 
64
 
 
65
 
60
66
#define DURSLEEP 250
61
67
#define DURHALFSLEEP DURSLEEP / 2
62
68
#define DURWAIT  300
91
97
}
92
98
 
93
99
 
 
100
 
 
101
void UniqueExpireLRUCacheTest::testAccessClear()
 
102
{
 
103
        UniqueAccessExpireLRUCache<int, DIntVal> aCache;
 
104
        aCache.add(1, DIntVal(2, DURSLEEP));
 
105
        aCache.add(3, DIntVal(4, DURSLEEP));
 
106
        aCache.add(5, DIntVal(6, DURSLEEP));
 
107
        assert (aCache.has(1));
 
108
        assert (aCache.has(3));
 
109
        assert (aCache.has(5));
 
110
        assert (aCache.get(1)->value() == 2);
 
111
        assert (aCache.get(3)->value() == 4);
 
112
        assert (aCache.get(5)->value() == 6);
 
113
        aCache.clear();
 
114
        assert (!aCache.has(1));
 
115
        assert (!aCache.has(3));
 
116
        assert (!aCache.has(5));
 
117
}
 
118
 
94
119
void UniqueExpireLRUCacheTest::testExpire0()
95
120
{
96
121
        UniqueExpireLRUCache<int, IntVal> aCache;
309
334
        CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("UniqueExpireLRUCacheTest");
310
335
 
311
336
        CppUnit_addTest(pSuite, UniqueExpireLRUCacheTest, testClear);
 
337
        CppUnit_addTest(pSuite, UniqueExpireLRUCacheTest, testAccessClear);
312
338
        CppUnit_addTest(pSuite, UniqueExpireLRUCacheTest, testExpire0);
313
339
        CppUnit_addTest(pSuite, UniqueExpireLRUCacheTest, testExpireN);
314
340
        CppUnit_addTest(pSuite, UniqueExpireLRUCacheTest, testCacheSize0);