changes for 1.2.4

This commit is contained in:
Guenter Obiltschnig
2006-09-29 14:39:00 +00:00
parent 245e2f7e83
commit 76edf6f35c
52 changed files with 1290 additions and 1056 deletions

View File

@@ -1,7 +1,7 @@
//
// ExpireCacheTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#2 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -47,7 +47,7 @@ using namespace Poco;
#define DURWAIT 300
ExpireCacheTest::ExpireCacheTest(const std::string& name ): CppUnit::TestCase(name)
ExpireCacheTest::ExpireCacheTest(const std::string& name): CppUnit::TestCase(name)
{
}
@@ -59,20 +59,20 @@ ExpireCacheTest::~ExpireCacheTest()
void ExpireCacheTest::testClear()
{
ExpireCache < int, int > aCache( DURSLEEP );
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2);
aCache.add(3, 4);
aCache.add(5, 6);
poco_assert ( aCache.has( 1 ) );
poco_assert ( aCache.has( 3 ) );
poco_assert ( aCache.has( 5 ) );
poco_assert ( *aCache.get( 1 ) == 2 );
poco_assert ( *aCache.get( 3 ) == 4 );
poco_assert ( *aCache.get( 5 ) == 6 );
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(1) == 2);
assert (*aCache.get(3) == 4);
assert (*aCache.get(5) == 6);
aCache.clear();
poco_assert ( !aCache.has( 1 ) );
poco_assert ( !aCache.has( 3 ) );
poco_assert ( !aCache.has( 5 ) );
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (!aCache.has(5));
}
@@ -80,10 +80,10 @@ void ExpireCacheTest::testExpire0()
{
try
{
ExpireCache < int, int > aCache( 24 );
failmsg ( "cache expire lower than 25 is illegal, test should fail");
ExpireCache<int, int> aCache(24);
failmsg("cache expire lower than 25 is illegal, test should fail");
}
catch ( Poco::InvalidArgumentException& )
catch (Poco::InvalidArgumentException&)
{
}
}
@@ -93,63 +93,63 @@ void ExpireCacheTest::testExpireN()
{
// 3-1 represents the cache sorted by age, elements get replaced at the end of the list
// 3-1|5 -> 5 gets removed
ExpireCache < int, int > aCache( DURSLEEP );
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
poco_assert ( aCache.has( 1 ) );
SharedPtr < int > tmp = aCache.get( 1 );
poco_assert ( tmp );
poco_assert ( *tmp == 2 );
Thread::sleep( DURWAIT );
poco_assert ( !aCache.has( 1 ) );
assert (aCache.has(1));
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
Thread::sleep(DURWAIT);
assert (!aCache.has(1));
// tmp must still be valid, access it
poco_assert ( *tmp == 2 );
tmp = aCache.get( 1 );
poco_assert ( !tmp );
assert (*tmp == 2);
tmp = aCache.get(1);
assert (!tmp);
aCache.add(1, 2); // 1
Thread::sleep( DURHALFSLEEP );
Thread::sleep(DURHALFSLEEP);
aCache.add(3, 4); // 3-1
poco_assert ( aCache.has( 1 ) );
poco_assert ( aCache.has( 3 ) );
tmp = aCache.get( 1 );
SharedPtr < int > tmp2 = aCache.get( 3 );
poco_assert ( *tmp == 2 );
poco_assert ( *tmp2 == 4 );
assert (aCache.has(1));
assert (aCache.has(3));
tmp = aCache.get(1);
SharedPtr<int> tmp2 = aCache.get(3);
assert (*tmp == 2);
assert (*tmp2 == 4);
Thread::sleep( DURHALFSLEEP+25 ); //3|1
poco_assert ( !aCache.has( 1 ) );
poco_assert ( aCache.has( 3 ) );
poco_assert ( *tmp == 2 ); // 1-3
poco_assert ( *tmp2 == 4 ); // 3-1
tmp2 = aCache.get( 3 );
poco_assert ( *tmp2 == 4 );
Thread::sleep( DURHALFSLEEP+25 ); //3|1
poco_assert ( !aCache.has( 3 ) );
poco_assert ( *tmp2 == 4 );
tmp = aCache.get( 1 );
tmp2 = aCache.get( 3 );
poco_assert ( !tmp );
poco_assert ( !tmp2 );
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (*tmp == 2); // 1-3
assert (*tmp2 == 4); // 3-1
tmp2 = aCache.get(3);
assert (*tmp2 == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(3));
assert (*tmp2 == 4);
tmp = aCache.get(1);
tmp2 = aCache.get(3);
assert (!tmp);
assert (!tmp2);
// removing illegal entries should work too
aCache.remove(666);
aCache.clear ();
poco_assert ( !aCache.has( 5 ) );
poco_assert ( !aCache.has( 3 ) );
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
}
void ExpireCacheTest::testDuplicateAdd()
{
ExpireCache < int, int > aCache( DURSLEEP );
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
poco_assert (aCache.has(1));
poco_assert (*aCache.get(1) == 2);
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
aCache.add(1, 3);
poco_assert (aCache.has(1));
poco_assert (*aCache.get(1) == 3);
assert (aCache.has(1));
assert (*aCache.get(1) == 3);
}