mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
changes for 1.2.4
This commit is contained in:
parent
245e2f7e83
commit
76edf6f35c
14
CHANGELOG
14
CHANGELOG
@ -1,5 +1,17 @@
|
||||
This is the changelog file for POCO - the C++ Portable Components.
|
||||
|
||||
Release 1.2.4 (2006-10-02)
|
||||
==========================
|
||||
|
||||
- some code beautifying and improvements to comments
|
||||
- DOMParser now automatically sets FEATURE_NAMESPACE_PREFIXES
|
||||
- fixed SF #1567051: DOMBuilder/DOMParser/NamespaceStrategy bug
|
||||
- fixed SF #1567364: POCO_APP_MAIN
|
||||
- added Document::getElementById() (two-argument) and getElementByIdNS()
|
||||
- added another test for DOMParser
|
||||
- added AutoPtr::isNull() (to be consistent with SharedPtr)
|
||||
|
||||
|
||||
Release 1.2.3 (2006-09-14)
|
||||
==========================
|
||||
|
||||
@ -499,4 +511,4 @@ building the libraries.
|
||||
|
||||
|
||||
--
|
||||
$Id: //poco/1.2/dist/CHANGELOG#6 $
|
||||
$Id: //poco/1.2/dist/CHANGELOG#7 $
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractCache.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -244,7 +244,6 @@ protected:
|
||||
mutable DataHolder _data;
|
||||
mutable FastMutex _mutex;
|
||||
|
||||
|
||||
private:
|
||||
AbstractCache(const AbstractCache& aCache);
|
||||
AbstractCache& operator = (const AbstractCache& aCache);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractStrategy.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AutoPtr.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -202,6 +202,11 @@ public:
|
||||
return _ptr;
|
||||
}
|
||||
|
||||
bool isNull() const
|
||||
{
|
||||
return _ptr == 0;
|
||||
}
|
||||
|
||||
operator C* ()
|
||||
{
|
||||
return _ptr;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ExpireCache.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ExpireLRUCache.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -66,7 +66,7 @@ public:
|
||||
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
|
||||
}
|
||||
|
||||
virtual ~ExpireLRUCache()
|
||||
~ExpireLRUCache()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ExpireStrategy.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -58,7 +58,7 @@ template <
|
||||
class TValue
|
||||
>
|
||||
class ExpireStrategy: public AbstractStrategy<TKey, TValue>
|
||||
/// An ExpireStrategy implements time based ecpiration of cache entries
|
||||
/// An ExpireStrategy implements time based expiration of cache entries
|
||||
{
|
||||
public:
|
||||
typedef std::multimap<Timestamp, TKey> TimeIndex;
|
||||
@ -75,7 +75,7 @@ public:
|
||||
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
||||
}
|
||||
|
||||
virtual ~ExpireStrategy()
|
||||
~ExpireStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Foundation.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -83,6 +83,7 @@
|
||||
//
|
||||
// Include platform-specific definitions
|
||||
//
|
||||
#include "Poco/Platform.h"
|
||||
#if defined(_WIN32)
|
||||
#include "Poco/Platform_WIN32.h"
|
||||
#elif defined(__VMS)
|
||||
@ -95,7 +96,6 @@
|
||||
//
|
||||
// Pull in basic definitions
|
||||
//
|
||||
#include "Poco/Platform.h"
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include "Poco/Types.h"
|
||||
#include <string>
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashTable.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// KeyValueArgs.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LRUCache.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -51,14 +51,13 @@ template <class TKey, class TValue>
|
||||
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
|
||||
/// An LRUCache is the interface of all caches.
|
||||
{
|
||||
|
||||
public:
|
||||
LRUCache(long size = 1024):
|
||||
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~LRUCache()
|
||||
~LRUCache()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LRUStrategy.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -71,7 +71,7 @@ public:
|
||||
if (_size < 1) throw InvalidArgumentException("size must be > 0");
|
||||
}
|
||||
|
||||
virtual ~LRUStrategy()
|
||||
~LRUStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedPtr.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#2 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -212,7 +212,7 @@ public:
|
||||
|
||||
bool isNull() const
|
||||
{
|
||||
return (_ptr == 0);
|
||||
return _ptr == 0;
|
||||
}
|
||||
|
||||
operator C* ()
|
||||
@ -351,7 +351,6 @@ private:
|
||||
_pCounter->duplicate();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ReferenceCounter* _pCounter;
|
||||
C* _ptr;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SimpleHashTable.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// StrategyCollection.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -64,7 +64,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~StrategyCollection()
|
||||
~StrategyCollection()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timestamp.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -80,6 +80,7 @@ public:
|
||||
/// Swaps the Timestamp with another one.
|
||||
|
||||
void update();
|
||||
/// Updates the Timestamp with the current time.
|
||||
|
||||
bool operator == (const Timestamp& ts) const;
|
||||
bool operator != (const Timestamp& ts) const;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ValidArgs.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileChannel.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/src/FileChannel.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/src/FileChannel.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SHA1Engine.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/src/SHA1Engine.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/src/SHA1Engine.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// pocomsg.mc[.h]
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/src/pocomsg.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/src/pocomsg.mc#1 $
|
||||
//
|
||||
// The Poco message source/header file.
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AnyTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/AnyTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/AnyTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -70,17 +70,17 @@ AnyTest::~AnyTest()
|
||||
void AnyTest::testInt()
|
||||
{
|
||||
Any a = 13;
|
||||
poco_assert (a.type() == typeid(int) );
|
||||
assert (a.type() == typeid(int));
|
||||
int* i = AnyCast<int>(&a);
|
||||
poco_assert ( *i == 13 );
|
||||
assert (*i == 13);
|
||||
Any b = a;
|
||||
poco_assert ( b.type() == typeid(int) );
|
||||
assert (b.type() == typeid(int));
|
||||
int *cpyI = AnyCast<int>(&b);
|
||||
poco_assert ( *cpyI == *i );
|
||||
assert (*cpyI == *i);
|
||||
*cpyI = 20;
|
||||
poco_assert ( *cpyI != *i );
|
||||
assert (*cpyI != *i);
|
||||
std::string* s = AnyCast<std::string>(&a);
|
||||
poco_assert ( s == NULL);
|
||||
assert (s == NULL);
|
||||
|
||||
int tmp = AnyCast<int>(a);
|
||||
const Any c = a;
|
||||
@ -93,14 +93,14 @@ void AnyTest::testComplexType()
|
||||
SomeClass str(13,std::string("hello"));
|
||||
Any a = str;
|
||||
Any b = a;
|
||||
poco_assert (a.type() == typeid(SomeClass) );
|
||||
poco_assert (b.type() == typeid(SomeClass) );
|
||||
assert (a.type() == typeid(SomeClass));
|
||||
assert (b.type() == typeid(SomeClass));
|
||||
SomeClass str2 = AnyCast<SomeClass>(a);
|
||||
poco_assert ( str == str2 );
|
||||
assert (str == str2);
|
||||
const SomeClass& strCRef = RefAnyCast<SomeClass>(a);
|
||||
poco_assert ( str == strCRef );
|
||||
assert (str == strCRef);
|
||||
SomeClass& strRef = RefAnyCast<SomeClass>(a);
|
||||
poco_assert ( str == strRef );
|
||||
assert (str == strRef);
|
||||
}
|
||||
|
||||
|
||||
@ -111,12 +111,12 @@ void AnyTest::testVector()
|
||||
tmp.push_back(2);
|
||||
tmp.push_back(3);
|
||||
Any a = tmp;
|
||||
poco_assert (a.type() == typeid(std::vector < int >) );
|
||||
assert (a.type() == typeid(std::vector<int>));
|
||||
std::vector<int>tmp2 = AnyCast<std::vector<int> >(a);
|
||||
const std::vector<int >& vecCRef = RefAnyCast<std::vector<int> >(a);
|
||||
std::vector<int >& vecRef = RefAnyCast<std::vector<int> >(a);
|
||||
vecRef[0] = 0;
|
||||
poco_assert( vecRef[0] == vecCRef[0] );
|
||||
assert (vecRef[0] == vecCRef[0]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AutoPtrTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/AutoPtrTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/AutoPtrTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// BasicEventTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/BasicEventTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/BasicEventTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -60,42 +60,42 @@ void BasicEventTest::testNoDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple -= Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex -= Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2 -= Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex -= Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex -= Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void BasicEventTest::testSingleDelegate()
|
||||
@ -103,36 +103,36 @@ void BasicEventTest::testSingleDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
|
||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 4 );
|
||||
assert (_count == 4);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 5 );
|
||||
assert (_count == 5);
|
||||
|
||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 6 );
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 7 );
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
@ -140,15 +140,15 @@ void BasicEventTest::testDuplicateRegister ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testDuplicateUnregister()
|
||||
@ -156,81 +156,81 @@ void BasicEventTest::testDuplicateUnregister ()
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple); // should work
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testDisabling()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
// unregister should also work with disabled event
|
||||
Simple.disable();
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testExpire()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
// renew registration
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
void BasicEventTest::testReturnParams()
|
||||
@ -240,7 +240,7 @@ void BasicEventTest::testReturnParams ()
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testOverwriteDelegate()
|
||||
@ -252,26 +252,26 @@ void BasicEventTest::testOverwriteDelegate ()
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
}
|
||||
|
||||
void BasicEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
||||
(*pSimple) += Delegate<BasicEventTest, int>(this, &BasicEventTest::onAsync);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
}
|
||||
|
||||
void BasicEventTest::onSimple(const void* pSender, int& i)
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// BasicEventTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/BasicEventTest.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/BasicEventTest.h#2 $
|
||||
//
|
||||
// Tests for BasicEvent
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ClassLoaderTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ClassLoaderTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ClassLoaderTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/DateTimeTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/DateTimeTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DummyDelegate.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/DummyDelegate.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/DummyDelegate.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -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.
|
||||
@ -63,16 +63,16 @@ void ExpireCacheTest::testClear()
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -95,49 +95,49 @@ void ExpireCacheTest::testExpireN()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireCache<int, int> aCache(DURSLEEP);
|
||||
aCache.add(1, 2); // 1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
assert (aCache.has(1));
|
||||
SharedPtr<int> tmp = aCache.get(1);
|
||||
poco_assert ( tmp );
|
||||
poco_assert ( *tmp == 2 );
|
||||
assert (!tmp.isNull());
|
||||
assert (*tmp == 2);
|
||||
Thread::sleep(DURWAIT);
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
assert (!aCache.has(1));
|
||||
|
||||
// tmp must still be valid, access it
|
||||
poco_assert ( *tmp == 2 );
|
||||
assert (*tmp == 2);
|
||||
tmp = aCache.get(1);
|
||||
poco_assert ( !tmp );
|
||||
assert (!tmp);
|
||||
|
||||
aCache.add(1, 2); // 1
|
||||
Thread::sleep(DURHALFSLEEP);
|
||||
aCache.add(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
tmp = aCache.get(1);
|
||||
SharedPtr<int> tmp2 = aCache.get(3);
|
||||
poco_assert ( *tmp == 2 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
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
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*tmp == 2); // 1-3
|
||||
assert (*tmp2 == 4); // 3-1
|
||||
tmp2 = aCache.get(3);
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (*tmp2 == 4);
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (!aCache.has(3));
|
||||
assert (*tmp2 == 4);
|
||||
tmp = aCache.get(1);
|
||||
tmp2 = aCache.get(3);
|
||||
poco_assert ( !tmp );
|
||||
poco_assert ( !tmp2 );
|
||||
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 ) );
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
@ -145,11 +145,11 @@ void ExpireCacheTest::testDuplicateAdd()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ExpireLRUCacheTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireLRUCacheTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireLRUCacheTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -63,16 +63,16 @@ void ExpireLRUCacheTest::testClear()
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -95,49 +95,49 @@ void ExpireLRUCacheTest::testExpireN()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache<int, int> aCache(3, DURSLEEP);
|
||||
aCache.add(1, 2); // 1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
assert (aCache.has(1));
|
||||
SharedPtr<int> tmp = aCache.get(1);
|
||||
poco_assert ( tmp );
|
||||
poco_assert ( *tmp == 2 );
|
||||
assert (!tmp.isNull());
|
||||
assert (*tmp == 2);
|
||||
Thread::sleep(DURWAIT);
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
assert (!aCache.has(1));
|
||||
|
||||
// tmp must still be valid, access it
|
||||
poco_assert ( *tmp == 2 );
|
||||
assert (*tmp == 2);
|
||||
tmp = aCache.get(1);
|
||||
poco_assert ( !tmp );
|
||||
assert (!tmp);
|
||||
|
||||
aCache.add(1, 2); // 1
|
||||
Thread::sleep(DURHALFSLEEP);
|
||||
aCache.add(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
tmp = aCache.get(1);
|
||||
SharedPtr<int> tmp2 = aCache.get(3);
|
||||
poco_assert ( *tmp == 2 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
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
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*tmp == 2); // 1-3
|
||||
assert (*tmp2 == 4); // 3-1
|
||||
tmp2 = aCache.get(3);
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (*tmp2 == 4);
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (!aCache.has(3));
|
||||
assert (*tmp2 == 4);
|
||||
tmp = aCache.get(1);
|
||||
tmp2 = aCache.get(3);
|
||||
poco_assert ( !tmp );
|
||||
poco_assert ( !tmp2 );
|
||||
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 ) );
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
@ -159,22 +159,22 @@ void ExpireLRUCacheTest::testCacheSize1()
|
||||
{
|
||||
ExpireLRUCache<int, int> aCache(1);
|
||||
aCache.add(1, 2);
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
||||
assert (aCache.has(1));
|
||||
assert (*aCache.get(1) == 2);
|
||||
|
||||
aCache.add(3, 4); // replaces 1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(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( 5 ) == 6 );
|
||||
assert (!aCache.has(1));
|
||||
assert (!aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6);
|
||||
|
||||
aCache.remove(5);
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(5));
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
@ -187,37 +187,37 @@ void ExpireLRUCacheTest::testCacheSize2()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache<int, int> aCache(2);
|
||||
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(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(1) == 2); // 1-3
|
||||
assert (*aCache.get(3) == 4); // 3-1
|
||||
|
||||
aCache.add(5, 6); // 5-3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-3
|
||||
assert (*aCache.get(3) == 4); // 3-5
|
||||
|
||||
// test remove from the end and the beginning of the list
|
||||
aCache.remove(5); // 3
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3
|
||||
assert (!aCache.has(5));
|
||||
assert (*aCache.get(3) == 4); // 3
|
||||
aCache.add(5, 6); // 5-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
||||
assert (*aCache.get(3) == 4); // 3-5
|
||||
aCache.remove(3); // 5
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5
|
||||
assert (!aCache.has(3));
|
||||
assert (*aCache.get(5) == 6); // 5
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
@ -227,48 +227,48 @@ void ExpireLRUCacheTest::testCacheSizeN()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache<int, int> aCache(3);
|
||||
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(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(1) == 2); // 1-3
|
||||
assert (*aCache.get(3) == 4); // 3-1
|
||||
|
||||
aCache.add(5, 6); // 5-3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3-1
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-3-1
|
||||
assert (*aCache.get(3) == 4); // 3-5-1
|
||||
|
||||
aCache.add(7, 8); // 7-5-3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 7 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-7-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-7
|
||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-3-5
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(7));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-7-3
|
||||
assert (*aCache.get(3) == 4); // 3-5-7
|
||||
assert (*aCache.get(7) == 8); // 7-3-5
|
||||
|
||||
// test remove from the end and the beginning of the list
|
||||
aCache.remove(5); // 7-3
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-7
|
||||
assert (!aCache.has(5));
|
||||
assert (*aCache.get(3) == 4); // 3-7
|
||||
aCache.add(5, 6); // 5-3-7
|
||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-5-3
|
||||
assert (*aCache.get(7) == 8); // 7-5-3
|
||||
aCache.remove(7); // 5-3
|
||||
poco_assert ( !aCache.has( 7 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
||||
assert (!aCache.has(7));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(5) == 6); // 5-3
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
@ -276,11 +276,11 @@ void ExpireLRUCacheTest::testDuplicateAdd()
|
||||
{
|
||||
ExpireLRUCache<int, int> aCache(3);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FIFOEventTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/FIFOEventTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/FIFOEventTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -60,42 +60,42 @@ void FIFOEventTest::testNoDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple -= Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex -= Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2 -= Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex -= Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex -= Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testSingleDelegate()
|
||||
@ -103,36 +103,36 @@ void FIFOEventTest::testSingleDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
|
||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 4 );
|
||||
assert (_count == 4);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 5 );
|
||||
assert (_count == 5);
|
||||
|
||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 6 );
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 7 );
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
@ -140,15 +140,15 @@ void FIFOEventTest::testDuplicateRegister ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testDuplicateUnregister()
|
||||
@ -156,23 +156,23 @@ void FIFOEventTest::testDuplicateUnregister ()
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple); // should work
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
@ -180,22 +180,22 @@ void FIFOEventTest::testDisabling ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
// unregister should also work with disabled event
|
||||
Simple.disable();
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testFIFOOrder()
|
||||
@ -203,13 +203,13 @@ void FIFOEventTest::testFIFOOrder ()
|
||||
DummyDelegate o1;
|
||||
DummyDelegate o2;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
@ -235,32 +235,32 @@ void FIFOEventTest::testFIFOOrderExpire ()
|
||||
DummyDelegate o1;
|
||||
DummyDelegate o2;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 5000);
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// both ways of unregistering should work
|
||||
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// now start mixing of expire and non expire
|
||||
tmp = 0;
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
||||
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||
@ -283,14 +283,14 @@ void FIFOEventTest::testExpire ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
@ -298,22 +298,22 @@ void FIFOEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
// renew registration
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
@ -324,7 +324,7 @@ void FIFOEventTest::testReturnParams ()
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testOverwriteDelegate()
|
||||
@ -336,26 +336,26 @@ void FIFOEventTest::testOverwriteDelegate ()
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
||||
(*pSimple) += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onAsync);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
}
|
||||
|
||||
void FIFOEventTest::onSimple(const void* pSender, int& i)
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FIFOEventTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/FIFOEventTest.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/FIFOEventTest.h#2 $
|
||||
//
|
||||
// Definition of the FIFOEventTest class.
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/HashTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/HashTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -55,14 +55,14 @@ void HashTest::testInsert()
|
||||
std::string s1("str1");
|
||||
std::string s2("str2");
|
||||
HashTable<std::string, int> hashTable;
|
||||
poco_assert (!hashTable.exists(s1));
|
||||
assert (!hashTable.exists(s1));
|
||||
hashTable.insert(s1, 13);
|
||||
poco_assert (hashTable.exists(s1));
|
||||
poco_assert (hashTable.get(s1) == 13);
|
||||
assert (hashTable.exists(s1));
|
||||
assert (hashTable.get(s1) == 13);
|
||||
int retVal = 0;
|
||||
|
||||
poco_assert (hashTable.get(s1, retVal));
|
||||
poco_assert (retVal == 13);
|
||||
assert (hashTable.get(s1, retVal));
|
||||
assert (retVal == 13);
|
||||
try
|
||||
{
|
||||
hashTable.insert(s1, 22);
|
||||
@ -76,9 +76,9 @@ void HashTest::testInsert()
|
||||
}
|
||||
catch (Exception&){}
|
||||
|
||||
poco_assert (!hashTable.exists(s2));
|
||||
assert (!hashTable.exists(s2));
|
||||
hashTable.insert(s2, 13);
|
||||
poco_assert (hashTable.exists(s2));
|
||||
assert (hashTable.exists(s2));
|
||||
}
|
||||
|
||||
|
||||
@ -90,16 +90,16 @@ void HashTest::testUpdate()
|
||||
HashTable<std::string, int> hashTable;
|
||||
hashTable.insert(s1, 13);
|
||||
hashTable.update(s1, 14);
|
||||
poco_assert (hashTable.exists(s1));
|
||||
poco_assert (hashTable.get(s1) == 14);
|
||||
assert (hashTable.exists(s1));
|
||||
assert (hashTable.get(s1) == 14);
|
||||
int retVal = 0;
|
||||
|
||||
poco_assert (hashTable.get(s1, retVal));
|
||||
poco_assert (retVal == 14);
|
||||
assert (hashTable.get(s1, retVal));
|
||||
assert (retVal == 14);
|
||||
|
||||
// updating a non existing item must work too
|
||||
hashTable.update(s2, 15);
|
||||
poco_assert (hashTable.get(s2) == 15);
|
||||
assert (hashTable.get(s2) == 15);
|
||||
}
|
||||
|
||||
|
||||
@ -114,8 +114,8 @@ void HashTest::testOverflow()
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
std::string tmp = Poco::NumberFormatter::format(i);
|
||||
poco_assert (hashTable.exists(tmp));
|
||||
poco_assert (hashTable.get(tmp) == i*i);
|
||||
assert (hashTable.exists(tmp));
|
||||
assert (hashTable.get(tmp) == i*i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,29 +123,29 @@ void HashTest::testOverflow()
|
||||
void HashTest::testSize()
|
||||
{
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
assert (hashTable.size() == 0);
|
||||
Poco::UInt32 h1 = hashTable.insert("1", 1);
|
||||
poco_assert (hashTable.size() == 1);
|
||||
assert (hashTable.size() == 1);
|
||||
Poco::UInt32 h2 = hashTable.update("2", 2);
|
||||
poco_assert (hashTable.size() == 2);
|
||||
assert (hashTable.size() == 2);
|
||||
hashTable.remove("1");
|
||||
poco_assert (hashTable.size() == 1);
|
||||
assert (hashTable.size() == 1);
|
||||
hashTable.remove("3");
|
||||
poco_assert (hashTable.size() == 1);
|
||||
assert (hashTable.size() == 1);
|
||||
hashTable.removeRaw("2", h2);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
assert (hashTable.size() == 0);
|
||||
hashTable.insert("1", 1);
|
||||
hashTable.insert("2", 2);
|
||||
poco_assert (hashTable.size() == 2);
|
||||
assert (hashTable.size() == 2);
|
||||
hashTable.clear();
|
||||
poco_assert (hashTable.size() == 0);
|
||||
assert (hashTable.size() == 0);
|
||||
}
|
||||
|
||||
|
||||
void HashTest::testResize()
|
||||
{
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
assert (hashTable.size() == 0);
|
||||
hashTable.resize(19);
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
@ -156,8 +156,8 @@ void HashTest::testResize()
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
std::string tmp = Poco::NumberFormatter::format(i);
|
||||
poco_assert (hashTable.exists(tmp));
|
||||
poco_assert (hashTable.get(tmp) == i*i);
|
||||
assert (hashTable.exists(tmp));
|
||||
assert (hashTable.get(tmp) == i*i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,18 +166,18 @@ void HashTest::testStatistic()
|
||||
{
|
||||
double relax = 0.001;
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
assert (hashTable.size() == 0);
|
||||
HashStatistic stat1(hashTable.currentState());
|
||||
poco_assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||
poco_assert (stat1.maxPositionsOfTable() == 13);
|
||||
poco_assert (stat1.maxEntriesPerHash() == 0);
|
||||
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||
assert (stat1.maxPositionsOfTable() == 13);
|
||||
assert (stat1.maxEntriesPerHash() == 0);
|
||||
|
||||
hashTable.resize(19);
|
||||
stat1 = hashTable.currentState(true);
|
||||
poco_assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||
poco_assert (stat1.maxPositionsOfTable() == 19);
|
||||
poco_assert (stat1.maxEntriesPerHash() == 0);
|
||||
poco_assert (stat1.detailedEntriesPerHash().size() == 19);
|
||||
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||
assert (stat1.maxPositionsOfTable() == 19);
|
||||
assert (stat1.maxEntriesPerHash() == 0);
|
||||
assert (stat1.detailedEntriesPerHash().size() == 19);
|
||||
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
@ -185,17 +185,17 @@ void HashTest::testStatistic()
|
||||
}
|
||||
stat1 = hashTable.currentState(true);
|
||||
double expAvg = 1024.0/ 19;
|
||||
poco_assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||
poco_assert (stat1.maxPositionsOfTable() == 19);
|
||||
poco_assert (stat1.maxEntriesPerHash() > expAvg);
|
||||
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||
assert (stat1.maxPositionsOfTable() == 19);
|
||||
assert (stat1.maxEntriesPerHash() > expAvg);
|
||||
hashTable.resize(1009);
|
||||
stat1 = hashTable.currentState(true);
|
||||
|
||||
expAvg = 1024.0/ 1009;
|
||||
|
||||
poco_assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||
poco_assert (stat1.maxPositionsOfTable() == 1009);
|
||||
poco_assert (stat1.maxEntriesPerHash() > expAvg);
|
||||
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||
assert (stat1.maxPositionsOfTable() == 1009);
|
||||
assert (stat1.maxEntriesPerHash() > expAvg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LRUCacheTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/LRUCacheTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/LRUCacheTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -57,16 +57,16 @@ void LRUCacheTest::testClear()
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -88,22 +88,22 @@ void LRUCacheTest::testCacheSize1()
|
||||
{
|
||||
LRUCache<int, int> aCache(1);
|
||||
aCache.add(1, 2);
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
||||
assert (aCache.has(1));
|
||||
assert (*aCache.get(1) == 2);
|
||||
|
||||
aCache.add(3, 4); // replaces 1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(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( 5 ) == 6 );
|
||||
assert (!aCache.has(1));
|
||||
assert (!aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6);
|
||||
|
||||
aCache.remove(5);
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(5));
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
@ -116,37 +116,37 @@ void LRUCacheTest::testCacheSize2()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
LRUCache<int, int> aCache(2);
|
||||
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(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(1) == 2); // 1-3
|
||||
assert (*aCache.get(3) == 4); // 3-1
|
||||
|
||||
aCache.add(5, 6); // 5-3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-3
|
||||
assert (*aCache.get(3) == 4); // 3-5
|
||||
|
||||
// test remove from the end and the beginning of the list
|
||||
aCache.remove(5); // 3
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3
|
||||
assert (!aCache.has(5));
|
||||
assert (*aCache.get(3) == 4); // 3
|
||||
aCache.add(5, 6); // 5-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
||||
assert (*aCache.get(3) == 4); // 3-5
|
||||
aCache.remove(3); // 5
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5
|
||||
assert (!aCache.has(3));
|
||||
assert (*aCache.get(5) == 6); // 5
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
@ -156,48 +156,48 @@ void LRUCacheTest::testCacheSizeN()
|
||||
// 3-1|5 -> 5 gets removed
|
||||
LRUCache<int, int> aCache(3);
|
||||
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(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(1) == 2); // 1-3
|
||||
assert (*aCache.get(3) == 4); // 3-1
|
||||
|
||||
aCache.add(5, 6); // 5-3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3-1
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-1
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-3-1
|
||||
assert (*aCache.get(3) == 4); // 3-5-1
|
||||
|
||||
aCache.add(7, 8); // 7-5-3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 7 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-7-3
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-7
|
||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-3-5
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(7));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(5) == 6); // 5-7-3
|
||||
assert (*aCache.get(3) == 4); // 3-5-7
|
||||
assert (*aCache.get(7) == 8); // 7-3-5
|
||||
|
||||
// test remove from the end and the beginning of the list
|
||||
aCache.remove(5); // 7-3
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-7
|
||||
assert (!aCache.has(5));
|
||||
assert (*aCache.get(3) == 4); // 3-7
|
||||
aCache.add(5, 6); // 5-3-7
|
||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-5-3
|
||||
assert (*aCache.get(7) == 8); // 7-5-3
|
||||
aCache.remove(7); // 5-3
|
||||
poco_assert ( !aCache.has( 7 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
||||
assert (!aCache.has(7));
|
||||
assert (aCache.has(3));
|
||||
assert (*aCache.get(5) == 6); // 5-3
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
@ -205,11 +205,11 @@ void LRUCacheTest::testDuplicateAdd()
|
||||
{
|
||||
LRUCache<int, int> aCache(3);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LoggerTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/LoggerTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/LoggerTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// PriorityEventTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/PriorityEventTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/PriorityEventTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -60,42 +60,42 @@ void PriorityEventTest::testNoDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
||||
Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testSingleDelegate()
|
||||
@ -103,43 +103,43 @@ void PriorityEventTest::testSingleDelegate()
|
||||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
// unregistering with a different priority --> different observer, is ignored
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 3);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 3);
|
||||
ConstSimple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 3);
|
||||
Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
|
||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 3);
|
||||
Complex2.notify(this, args);
|
||||
poco_assert ( _count == 4 );
|
||||
assert (_count == 4);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 3);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
poco_assert ( _count == 5 );
|
||||
assert (_count == 5);
|
||||
|
||||
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
||||
Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 3);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 6 );
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
poco_assert ( _count == 7 );
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
@ -147,23 +147,23 @@ void PriorityEventTest::testDuplicateRegister ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 + LARGEINC );
|
||||
assert (_count == 2 + LARGEINC);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 + LARGEINC );
|
||||
assert (_count == 3 + LARGEINC);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testDuplicateUnregister()
|
||||
@ -171,23 +171,23 @@ void PriorityEventTest::testDuplicateUnregister ()
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0); // should work
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
@ -195,22 +195,22 @@ void PriorityEventTest::testDisabling ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
|
||||
// unregister should also work with disabled event
|
||||
Simple.disable();
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testPriorityOrder()
|
||||
@ -218,14 +218,14 @@ void PriorityEventTest::testPriorityOrder ()
|
||||
DummyDelegate o1;
|
||||
DummyDelegate o2;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
@ -254,19 +254,19 @@ void PriorityEventTest::testPriorityOrderExpire ()
|
||||
DummyDelegate o1;
|
||||
DummyDelegate o2;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 500000);
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// both ways of unregistering should work
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// now start mixing of expire and non expire
|
||||
tmp = 0;
|
||||
@ -274,13 +274,13 @@ void PriorityEventTest::testPriorityOrderExpire ()
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
||||
@ -305,14 +305,14 @@ void PriorityEventTest::testExpire ()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
}
|
||||
|
||||
@ -321,22 +321,22 @@ void PriorityEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 1 );
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 2 );
|
||||
assert (_count == 2);
|
||||
// renew registration
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( _count == 3 );
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
@ -347,7 +347,7 @@ void PriorityEventTest::testReturnParams ()
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testOverwriteDelegate()
|
||||
@ -359,11 +359,11 @@ void PriorityEventTest::testOverwriteDelegate ()
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 1 );
|
||||
assert (tmp == 1);
|
||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
poco_assert ( tmp == 2 );
|
||||
assert (tmp == 2);
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
||||
}
|
||||
|
||||
@ -371,15 +371,15 @@ void PriorityEventTest::testAsyncNotify ()
|
||||
{
|
||||
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
||||
(*pSimple) += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onAsync, 0);
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// PriorityEventTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/PriorityEventTest.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/PriorityEventTest.h#2 $
|
||||
//
|
||||
// Definition of the PriorityEventTest class.
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedPtrTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/SharedPtrTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/SharedPtrTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TimerTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/TimerTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/TimerTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -63,7 +63,6 @@ void TimerTest::testTimer()
|
||||
TimerCallback<TimerTest> tc(*this, &TimerTest::onTimer);
|
||||
sw.start();
|
||||
t.start(tc);
|
||||
/***
|
||||
_event.wait();
|
||||
sw.stop();
|
||||
assert (sw.elapsed() >= 90000 && sw.elapsed() < 150000);
|
||||
@ -75,7 +74,6 @@ void TimerTest::testTimer()
|
||||
_event.wait();
|
||||
sw.stop();
|
||||
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000);
|
||||
***/
|
||||
t.stop();
|
||||
}
|
||||
|
||||
|
4
NEWS
4
NEWS
@ -1,4 +1,4 @@
|
||||
Release 1.2.3 (2006-09-14)
|
||||
Release 1.2.4 (2006-10-02)
|
||||
==========================
|
||||
|
||||
This release contains bugfixes and minor enchancements.
|
||||
@ -124,4 +124,4 @@ Please refer to the README file for more information and instructions for
|
||||
building the libraries.
|
||||
|
||||
--
|
||||
$Id: //poco/1.2/dist/NEWS#4 $
|
||||
$Id: //poco/1.2/dist/NEWS#5 $
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Application.h
|
||||
//
|
||||
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#1 $
|
||||
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
@ -418,7 +418,7 @@ inline Poco::Timespan Application::uptime() const
|
||||
#define POCO_APP_MAIN(App) \
|
||||
int wmain(int argc, wchar_t** argv) \
|
||||
{ \
|
||||
AutoPtr<SampleApp> pApp = new App; \
|
||||
AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(argc, argv); \
|
||||
@ -434,7 +434,7 @@ inline Poco::Timespan Application::uptime() const
|
||||
#define POCO_APP_MAIN(App) \
|
||||
int main(int argc, char** argv) \
|
||||
{ \
|
||||
AutoPtr<SampleApp> pApp = new App; \
|
||||
AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(argc, argv); \
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Document.h
|
||||
//
|
||||
// $Id: //poco/1.2/XML/include/Poco/DOM/Document.h#1 $
|
||||
// $Id: //poco/1.2/XML/include/Poco/DOM/Document.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -209,6 +209,9 @@ public:
|
||||
/// are not of type ID unless so defined. Implementations that do
|
||||
/// not know whether attributes are of type ID or not are expected to
|
||||
/// return null. This implementation therefore returns null.
|
||||
///
|
||||
/// See also the non-standard two argument variant of getElementById()
|
||||
/// and getElementByIdNS().
|
||||
|
||||
// DocumentEvent
|
||||
Event* createEvent(const XMLString& eventType) const;
|
||||
@ -231,6 +234,18 @@ public:
|
||||
///
|
||||
/// This method is not part of the W3C Document Object Model.
|
||||
|
||||
Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const;
|
||||
/// Returns the first Element whose ID attribute (given in idAttribute)
|
||||
/// has the given elementId. If no such element exists, returns null.
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const;
|
||||
/// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName)
|
||||
/// has the given elementId. If no such element exists, returns null.
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
protected:
|
||||
~Document();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Element.h
|
||||
//
|
||||
// $Id: //poco/1.2/XML/include/Poco/DOM/Element.h#1 $
|
||||
// $Id: //poco/1.2/XML/include/Poco/DOM/Element.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -79,6 +79,9 @@ public:
|
||||
|
||||
const XMLString& getAttribute(const XMLString& name) const;
|
||||
/// Retrieves an attribute value by name.
|
||||
///
|
||||
/// Returns the attribute's value, if the attribute
|
||||
/// exists, or an empty string otherwise.
|
||||
|
||||
void setAttribute(const XMLString& name, const XMLString& value);
|
||||
/// Adds a new attribute. If an attribute with that name is already present
|
||||
@ -127,6 +130,9 @@ public:
|
||||
// DOM Level 2
|
||||
const XMLString& getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
/// Retrieves an attribute value by name.
|
||||
///
|
||||
/// Returns the attribute's value, if the attribute
|
||||
/// exists, or an empty string otherwise.
|
||||
|
||||
void setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value);
|
||||
/// Adds a new attribute. If an attribute with that name
|
||||
@ -178,6 +184,18 @@ public:
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const;
|
||||
/// Returns the first Element whose ID attribute (given in idAttribute)
|
||||
/// has the given elementId. If no such element exists, returns null.
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const;
|
||||
/// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName)
|
||||
/// has the given elementId. If no such element exists, returns null.
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
// Node
|
||||
const XMLString& nodeName() const;
|
||||
NamedNodeMap* attributes() const;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DOMParser.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/src/DOMParser.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/src/DOMParser.cpp#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -54,6 +54,8 @@ DOMParser::DOMParser(NamePool* pNamePool):
|
||||
_whitespace(true)
|
||||
{
|
||||
if (_pNamePool) _pNamePool->duplicate();
|
||||
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
|
||||
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Document.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/src/Document.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/src/Document.cpp#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -306,4 +306,20 @@ Notation* Document::createNotation(const XMLString& name, const XMLString& publi
|
||||
}
|
||||
|
||||
|
||||
Element* Document::getElementById(const XMLString& elementId, const XMLString& idAttribute) const
|
||||
{
|
||||
Element* pElem = documentElement();
|
||||
if (pElem) pElem = pElem->getElementById(elementId, idAttribute);
|
||||
return pElem;
|
||||
}
|
||||
|
||||
|
||||
Element* Document::getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const
|
||||
{
|
||||
Element* pElem = documentElement();
|
||||
if (pElem) pElem = pElem->getElementByIdNS(elementId, idAttributeURI, idAttributeLocalName);
|
||||
return pElem;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Element.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/src/Element.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/src/Element.cpp#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -404,5 +404,42 @@ Node* Element::copyNode(bool deep, Document* pOwnerDocument) const
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
Element* Element::getElementById(const XMLString& elementId, const XMLString& idAttribute) const
|
||||
{
|
||||
if (getAttribute(idAttribute) == elementId)
|
||||
return const_cast<Element*>(this);
|
||||
|
||||
Node* pNode = firstChild();
|
||||
while (pNode)
|
||||
{
|
||||
if (pNode->nodeType() == Node::ELEMENT_NODE)
|
||||
{
|
||||
Element* pResult = static_cast<Element*>(pNode)->getElementById(elementId, idAttribute);
|
||||
if (pResult) return pResult;
|
||||
}
|
||||
pNode = pNode->nextSibling();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Element* Element::getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const
|
||||
{
|
||||
if (getAttributeNS(idAttributeURI, idAttributeLocalName) == elementId)
|
||||
return const_cast<Element*>(this);
|
||||
|
||||
Node* pNode = firstChild();
|
||||
while (pNode)
|
||||
{
|
||||
if (pNode->nodeType() == Node::ELEMENT_NODE)
|
||||
{
|
||||
Element* pResult = static_cast<Element*>(pNode)->getElementByIdNS(elementId, idAttributeURI, idAttributeLocalName);
|
||||
if (pResult) return pResult;
|
||||
}
|
||||
pNode = pNode->nextSibling();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// NamespaceStrategy.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
@ -184,15 +184,19 @@ void NamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar*
|
||||
const XMLChar* attrValue = *atts++;
|
||||
XMLString attrURI;
|
||||
XMLString attrLocal;
|
||||
XMLString attrPrefix;
|
||||
splitName(attrName, attrURI, attrLocal, attrPrefix);
|
||||
attributes.addAttribute(attrURI, attrLocal, attrPrefix, CDATA, attrValue, i < specifiedCount);
|
||||
XMLString attrQName;
|
||||
splitName(attrName, attrURI, attrLocal, attrQName);
|
||||
if (!attrQName.empty()) attrQName.append(":");
|
||||
attrQName.append(attrLocal);
|
||||
attributes.addAttribute(attrURI, attrLocal, attrQName, CDATA, attrValue, i < specifiedCount);
|
||||
}
|
||||
XMLString uri;
|
||||
XMLString local;
|
||||
XMLString prefix;
|
||||
splitName(name, uri, local, prefix);
|
||||
pContentHandler->startElement(uri, local, prefix, attributes);
|
||||
XMLString qname;
|
||||
splitName(name, uri, local, qname);
|
||||
if (!qname.empty()) qname.append(":");
|
||||
qname.append(local);
|
||||
pContentHandler->startElement(uri, local, qname, attributes);
|
||||
}
|
||||
|
||||
|
||||
@ -202,9 +206,11 @@ void NamespacePrefixesStrategy::endElement(const XMLChar* name, ContentHandler*
|
||||
|
||||
XMLString uri;
|
||||
XMLString local;
|
||||
XMLString prefix;
|
||||
splitName(name, uri, local, prefix);
|
||||
pContentHandler->endElement(uri, local, prefix);
|
||||
XMLString qname;
|
||||
splitName(name, uri, local, qname);
|
||||
if (!qname.empty()) qname.append(":");
|
||||
qname.append(local);
|
||||
pContentHandler->endElement(uri, local, qname);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DocumentTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/testsuite/src/DocumentTest.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/testsuite/src/DocumentTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -203,6 +203,87 @@ void DocumentTest::testElementsByTagNameNS()
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementById()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pRoot->setAttribute("id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
pElem1->setAttribute("id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
pElem2->setAttribute("id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
pElem3->setAttribute("id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementById("0", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementById("1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementById("2", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementById("3", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementById("4", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementById("0", "ID");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementByIdNS()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
|
||||
pRoot->setAttributeNS("urn:ns1", "id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem1->setAttributeNS("urn:ns1", "id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem2->setAttributeNS("urn:ns1", "id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem3->setAttributeNS("urn:ns1", "id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementByIdNS("0", "urn:ns1", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("1", "urn:ns1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("2", "urn:ns1", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("3", "urn:ns1", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("4", "urn:ns1", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns1", "ID");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns2", "id");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -222,6 +303,8 @@ CppUnit::Test* DocumentTest::suite()
|
||||
CppUnit_addTest(pSuite, DocumentTest, testImportDeep);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagName);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagNameNS);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementById);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementByIdNS);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DocumentTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/XML/testsuite/src/DocumentTest.h#1 $
|
||||
// $Id: //poco/1.2/XML/testsuite/src/DocumentTest.h#2 $
|
||||
//
|
||||
// Definition of the DocumentTest class.
|
||||
//
|
||||
@ -51,6 +51,8 @@ public:
|
||||
void testImportDeep();
|
||||
void testElementsByTagName();
|
||||
void testElementsByTagNameNS();
|
||||
void testElementById();
|
||||
void testElementByIdNS();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ParserWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/XML/testsuite/src/ParserWriterTest.cpp#1 $
|
||||
// $Id: //poco/1.2/XML/testsuite/src/ParserWriterTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -45,6 +45,7 @@
|
||||
|
||||
using Poco::XML::DOMParser;
|
||||
using Poco::XML::DOMWriter;
|
||||
using Poco::XML::XMLReader;
|
||||
using Poco::XML::XMLWriter;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::AutoPtr;
|
||||
@ -66,6 +67,7 @@ void ParserWriterTest::testParseWriteXHTML()
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
@ -75,6 +77,21 @@ void ParserWriterTest::testParseWriteXHTML()
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteXHTML2()
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML2);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == XHTML2);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteWSDL()
|
||||
{
|
||||
std::istringstream istr(WSDL);
|
||||
@ -82,6 +99,7 @@ void ParserWriterTest::testParseWriteWSDL()
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(DOMParser::FEATURE_WHITESPACE, false);
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
writer.setOptions(XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
|
||||
writer.setNewLine(XMLWriter::NEWLINE_LF);
|
||||
@ -109,6 +127,7 @@ CppUnit::Test* ParserWriterTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ParserWriterTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML2);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteWSDL);
|
||||
|
||||
return pSuite;
|
||||
@ -136,6 +155,27 @@ const std::string ParserWriterTest::XHTML =
|
||||
"</ns1:html>";
|
||||
|
||||
|
||||
const std::string ParserWriterTest::XHTML2 =
|
||||
"<!--\n"
|
||||
"\tThis is a comment.\n"
|
||||
"-->"
|
||||
"<xns:html xml:lang=\"en\" xmlns:xns=\"http://www.w3.org/1999/xhtml\">\n"
|
||||
"\t<xns:head>\n"
|
||||
"\t\t<xns:link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
|
||||
"\t\t<?xml-stylesheet href=\"styles.css\" type=\"text/css\"?>\n"
|
||||
"\t\t<xns:title>A XHTML Example</xns:title>\n"
|
||||
"\t</xns:head>\n"
|
||||
"\t<xns:body>\n"
|
||||
"\t\t<xns:h1>XHTML Example</xns:h1>\n"
|
||||
"\t\t<xns:p>This is a XHTML example page.</xns:p>\n"
|
||||
"\t\t<xns:img alt=\"Example Picture\" border=\"0\" height=\"192\" src=\"example.gif\" width=\"256\"/>\n"
|
||||
"\t\t<![CDATA[\n"
|
||||
"\t\tThe following <tag attr=\"value\">is inside a CDATA section</tag>.\n"
|
||||
"\t\t]]>\n"
|
||||
"\t</xns:body>\n"
|
||||
"</xns:html>";
|
||||
|
||||
|
||||
const std::string ParserWriterTest::WSDL =
|
||||
"<!-- WSDL description of the Google Web APIs.\n"
|
||||
" The Google Web APIs are in beta release. All interfaces are subject to\n"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ParserWriterTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/XML/testsuite/src/ParserWriterTest.h#1 $
|
||||
// $Id: //poco/1.2/XML/testsuite/src/ParserWriterTest.h#2 $
|
||||
//
|
||||
// Definition of the ParserWriterTest class.
|
||||
//
|
||||
@ -47,6 +47,7 @@ public:
|
||||
~ParserWriterTest();
|
||||
|
||||
void testParseWriteXHTML();
|
||||
void testParseWriteXHTML2();
|
||||
void testParseWriteWSDL();
|
||||
|
||||
void setUp();
|
||||
@ -56,6 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
static const std::string XHTML;
|
||||
static const std::string XHTML2;
|
||||
static const std::string WSDL;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user