changes for 1.2.4
This commit is contained in:
Родитель
245e2f7e83
Коммит
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
|
||||
|
@ -70,12 +70,12 @@ public:
|
|||
typedef typename DataHolder::const_iterator ConstIterator;
|
||||
typedef std::set<TKey> KeySet;
|
||||
|
||||
AbstractCache()
|
||||
AbstractCache()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
AbstractCache(const TStrategy& strat):_strategy(strat)
|
||||
AbstractCache(const TStrategy& strat): _strategy(strat)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
{
|
||||
uninitialize();
|
||||
}
|
||||
|
||||
|
||||
void add(const TKey& key, const TValue& val)
|
||||
/// Adds the key value pair to the cache.
|
||||
/// If for the key already an entry exists, it will be overwritten.
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
FastMutex::ScopedLock lock(_mutex);
|
||||
doAdd(key, val);
|
||||
}
|
||||
|
||||
|
||||
void remove(const TKey& key)
|
||||
/// Removes an entry from the cache. If the entry is not found,
|
||||
/// the remove is ignored.
|
||||
|
@ -100,13 +100,13 @@ public:
|
|||
FastMutex::ScopedLock lock(_mutex);
|
||||
doRemove(key);
|
||||
}
|
||||
|
||||
|
||||
bool has(const TKey& key) const
|
||||
/// Returns true if the cache contains a value for the key.
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
return doHas(key);
|
||||
}
|
||||
}
|
||||
|
||||
SharedPtr<TValue> get(const TKey& key)
|
||||
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
FastMutex::ScopedLock lock(_mutex);
|
||||
return doGet (key);
|
||||
}
|
||||
|
||||
|
||||
void clear()
|
||||
/// Removes all elements from the cache.
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ protected:
|
|||
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
||||
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
||||
}
|
||||
|
||||
|
||||
void uninitialize()
|
||||
/// Reverts event registration.
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ protected:
|
|||
|
||||
doReplace();
|
||||
}
|
||||
|
||||
|
||||
void doRemove(const TKey& key)
|
||||
/// Removes an entry from the cache. If the entry is not found
|
||||
/// the remove is ignored.
|
||||
|
@ -173,7 +173,7 @@ protected:
|
|||
Remove.notify(this, key);
|
||||
_data.erase(key);
|
||||
}
|
||||
|
||||
|
||||
bool doHas(const TKey& key) const
|
||||
/// Returns true if the cache contains a value for the key
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ protected:
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void doClear()
|
||||
{
|
||||
static EventArgs _emptyArgs;
|
||||
|
@ -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
|
||||
|
@ -53,8 +53,8 @@ class AbstractStrategy
|
|||
/// An AbstractStrategy is the interface for all strategies.
|
||||
{
|
||||
public:
|
||||
AbstractStrategy()
|
||||
{
|
||||
AbstractStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AbstractStrategy()
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
virtual void onGet(const void* pSender, const TKey& key) = 0;
|
||||
/// Informs the strategy that a read-access happens to an element.
|
||||
|
||||
|
||||
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
|
||||
/// Removes all elements from the 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
|
||||
|
@ -151,18 +151,18 @@ public:
|
|||
}
|
||||
|
||||
template <class Other>
|
||||
AutoPtr < Other > cast()
|
||||
AutoPtr<Other> cast()
|
||||
/// Casts the AutoPtr via a dynamic cast to the given type.
|
||||
/// Returns an AutoPtr containing NULL if the cast fails.
|
||||
/// Example: (assume class Sub: public Super)
|
||||
/// AutoPtr < Super > super(new Sub());
|
||||
/// AutoPtr < Sub > sub = super.cast<Sub>();
|
||||
/// AutoPtr<Super> super(new Sub());
|
||||
/// AutoPtr<Sub> sub = super.cast<Sub>();
|
||||
/// poco_assert (sub.get());
|
||||
{
|
||||
Other* pOther = dynamic_cast <Other*>(_ptr);
|
||||
if (pOther)
|
||||
pOther->duplicate();
|
||||
return AutoPtr < Other > (pOther);
|
||||
return AutoPtr<Other>(pOther);
|
||||
}
|
||||
|
||||
C* operator -> ()
|
||||
|
@ -201,6 +201,11 @@ public:
|
|||
{
|
||||
return _ptr;
|
||||
}
|
||||
|
||||
bool isNull() const
|
||||
{
|
||||
return _ptr == 0;
|
||||
}
|
||||
|
||||
operator C* ()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
@ -48,7 +48,7 @@ namespace Poco {
|
|||
|
||||
|
||||
template <class TKey, class TValue>
|
||||
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue > >
|
||||
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >
|
||||
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
|
||||
/// Be careful when using an ExpireCache. A cache is often used
|
||||
/// like cache.has(x) followed by cache.get x). Note that it could happen
|
||||
|
|
|
@ -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
|
||||
|
@ -52,7 +52,7 @@ namespace Poco {
|
|||
template <
|
||||
class TKey,
|
||||
class TValue
|
||||
>
|
||||
>
|
||||
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
|
||||
/// An ExpireLRUCache combines LUR caching and time based expire caching.
|
||||
/// It cache entries for a fixed time period (per default 10 minutes)
|
||||
|
@ -66,10 +66,10 @@ public:
|
|||
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
|
||||
}
|
||||
|
||||
virtual ~ExpireLRUCache()
|
||||
~ExpireLRUCache()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ExpireLRUCache(const ExpireLRUCache& aCache);
|
||||
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
|
||||
|
|
|
@ -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
|
||||
|
@ -56,15 +56,15 @@ namespace Poco {
|
|||
template <
|
||||
class TKey,
|
||||
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;
|
||||
typedef typename TimeIndex::iterator IndexIterator;
|
||||
typedef typename TimeIndex::const_iterator ConstIndexIterator;
|
||||
typedef std::map<TKey, IndexIterator> Keys;
|
||||
typedef std::map<TKey, IndexIterator> Keys;
|
||||
typedef typename Keys::iterator Iterator;
|
||||
|
||||
public:
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
||||
}
|
||||
|
||||
virtual ~ExpireStrategy()
|
||||
~ExpireStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
{
|
||||
Timestamp now;
|
||||
IndexIterator it = _keyIndex.insert(std::make_pair(now, args.key()));
|
||||
std::pair < Iterator, bool > stat = _keys.insert(std::make_pair(args.key(), it));
|
||||
std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it));
|
||||
if (!stat.second)
|
||||
{
|
||||
_keyIndex.erase(stat.first->second);
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
void onRemove(const void*, const TKey& key)
|
||||
{
|
||||
Iterator it = _keys.find(key);
|
||||
if (it != _keys.end ())
|
||||
if (it != _keys.end())
|
||||
{
|
||||
_keyIndex.erase(it->second);
|
||||
_keys.erase(it);
|
||||
|
@ -111,11 +111,11 @@ public:
|
|||
_keys.clear();
|
||||
_keyIndex.clear();
|
||||
}
|
||||
|
||||
|
||||
void onIsValid(const void*, ValidArgs<TKey>& args)
|
||||
{
|
||||
Iterator it = _keys.find(args.key());
|
||||
if (it != _keys.end ())
|
||||
if (it != _keys.end())
|
||||
{
|
||||
if (it->second->first.isElapsed(_expireTime))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
{
|
||||
if (!_entries[hsh])
|
||||
_entries[hsh] = new HashEntryMap();
|
||||
std::pair < Iterator, bool > res = _entries[hsh]->insert(make_pair(key, value));
|
||||
std::pair<Iterator, bool> res = _entries[hsh]->insert(make_pair(key, value));
|
||||
if (res.second == false)
|
||||
res.first->second = value;
|
||||
else
|
||||
|
|
|
@ -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
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const TKey& key() const
|
||||
const TKey& key() const
|
||||
/// Returns a reference to the key,
|
||||
{
|
||||
return _key;
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
const TKey& _key;
|
||||
const TValue& _value;
|
||||
|
|
|
@ -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):
|
||||
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
|
||||
|
@ -52,7 +52,7 @@
|
|||
namespace Poco {
|
||||
|
||||
|
||||
template <class TKey, class TValue>
|
||||
template <class TKey, class TValue>
|
||||
class LRUStrategy: public AbstractStrategy<TKey, TValue>
|
||||
/// An LRUStrategy implements least recently used cache replacement.
|
||||
{
|
||||
|
@ -71,14 +71,14 @@ public:
|
|||
if (_size < 1) throw InvalidArgumentException("size must be > 0");
|
||||
}
|
||||
|
||||
virtual ~LRUStrategy()
|
||||
~LRUStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
|
||||
{
|
||||
_keys.push_front(args.key());
|
||||
std::pair < IndexIterator, bool > stat = _keyIndex.insert(make_pair(args.key(), _keys.begin()));
|
||||
std::pair<IndexIterator, bool> stat = _keyIndex.insert(make_pair(args.key(), _keys.begin()));
|
||||
if (!stat.second)
|
||||
{
|
||||
stat.first->second = _keys.begin();
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
}
|
||||
|
||||
size_t diff = curSize - _size;
|
||||
Iterator it = --_keys.end (); //--keys can never be invoked on an empty list due to the minSize==1 requirement of LRU
|
||||
Iterator it = --_keys.end(); //--keys can never be invoked on an empty list due to the minSize==1 requirement of LRU
|
||||
size_t i = 0;
|
||||
|
||||
while (i++ < diff)
|
||||
|
|
|
@ -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
|
||||
|
@ -166,18 +166,18 @@ public:
|
|||
}
|
||||
|
||||
template <class Other>
|
||||
SharedPtr < Other > cast()
|
||||
SharedPtr<Other> cast()
|
||||
/// Casts the SharedPtr via a dynamic cast to the given type.
|
||||
/// Returns an SharedPtr containing NULL if the cast fails.
|
||||
/// Example: (assume class Sub: public Super)
|
||||
/// SharedPtr < Super > super(new Sub());
|
||||
/// SharedPtr < Sub > sub = super.cast<Sub>();
|
||||
/// SharedPtr<Super> super(new Sub());
|
||||
/// SharedPtr<Sub> sub = super.cast<Sub>();
|
||||
/// poco_assert (sub.get());
|
||||
{
|
||||
Other* pOther = dynamic_cast <Other*>(_ptr);
|
||||
if (pOther)
|
||||
return SharedPtr < Other > (_pCounter, pOther);
|
||||
return SharedPtr < Other > ();
|
||||
return SharedPtr<Other> (_pCounter, pOther);
|
||||
return SharedPtr<Other>();
|
||||
}
|
||||
|
||||
void swap(SharedPtr& ptr)
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
|
||||
bool isNull() const
|
||||
{
|
||||
return (_ptr == 0);
|
||||
return _ptr == 0;
|
||||
}
|
||||
|
||||
operator C* ()
|
||||
|
@ -344,19 +344,18 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
SharedPtr(ReferenceCounter* pCounter, C* ptr):_pCounter(pCounter), _ptr(ptr)
|
||||
SharedPtr(ReferenceCounter* pCounter, C* ptr): _pCounter(pCounter), _ptr(ptr)
|
||||
/// for cast operation
|
||||
{
|
||||
poco_assert_dbg (_pCounter);
|
||||
_pCounter->duplicate();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ReferenceCounter* _pCounter;
|
||||
C* _ptr;
|
||||
|
||||
template < class Other > friend class SharedPtr;
|
||||
template<class Other> friend class SharedPtr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
UInt32 origHash = hsh;
|
||||
while (_entries[hsh % _maxCapacity])
|
||||
{
|
||||
if(_entries[hsh % _maxCapacity]->key == key)
|
||||
if (_entries[hsh % _maxCapacity]->key == key)
|
||||
{
|
||||
_entries[hsh % _maxCapacity]->value = value;
|
||||
return;
|
||||
|
@ -225,7 +225,7 @@ public:
|
|||
{
|
||||
if (_entries[hsh % _maxCapacity])
|
||||
{
|
||||
if(_entries[hsh % _maxCapacity]->key == key)
|
||||
if (_entries[hsh % _maxCapacity]->key == key)
|
||||
{
|
||||
return _entries[hsh % _maxCapacity]->value;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public:
|
|||
{
|
||||
if (_entries[hsh % _maxCapacity])
|
||||
{
|
||||
if(_entries[hsh % _maxCapacity]->key == key)
|
||||
if (_entries[hsh % _maxCapacity]->key == key)
|
||||
{
|
||||
return _entries[hsh % _maxCapacity]->key;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public:
|
|||
{
|
||||
if (_entries[hsh % _maxCapacity])
|
||||
{
|
||||
if(_entries[hsh % _maxCapacity]->key == key)
|
||||
if (_entries[hsh % _maxCapacity]->key == key)
|
||||
{
|
||||
v = _entries[hsh % _maxCapacity]->value;
|
||||
return true;
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
{
|
||||
if (_entries[hsh % _maxCapacity])
|
||||
{
|
||||
if(_entries[hsh % _maxCapacity]->key == key)
|
||||
if (_entries[hsh % _maxCapacity]->key == key)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -60,14 +60,14 @@ public:
|
|||
typedef typename Strategies::const_iterator ConstIterator;
|
||||
|
||||
public:
|
||||
StrategyCollection()
|
||||
StrategyCollection()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~StrategyCollection()
|
||||
{
|
||||
~StrategyCollection()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void pushBack(AbstractStrategy<TKey, TValue>* pStrat)
|
||||
/// Adds an AbstractStrategy to the collection. Class takes ownership of pointer
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
/// Removes the last added AbstractStrategy from the collection.
|
||||
{
|
||||
_strategies.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key)
|
||||
/// Adds the key to the strategy.
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
(*it)->onRemove(pSender, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onGet(const void* pSender, const TKey& key)
|
||||
{
|
||||
Iterator it = _strategies.begin();
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
(*it)->onGet(pSender, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onClear(const void* pSender, const EventArgs& args)
|
||||
{
|
||||
Iterator it = _strategies.begin();
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
{
|
||||
Iterator it = _strategies.begin();
|
||||
Iterator endIt = _strategies.end();
|
||||
for (; it != endIt && key.isValid (); ++it)
|
||||
for (; it != endIt && key.isValid(); ++it)
|
||||
{
|
||||
(*it)->onIsValid(pSender, key);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -46,7 +46,7 @@
|
|||
namespace Poco {
|
||||
|
||||
|
||||
template <class TKey>
|
||||
template <class TKey>
|
||||
class ValidArgs
|
||||
{
|
||||
public:
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
const TKey& _key;
|
||||
const TKey& _key;
|
||||
bool _isValid;
|
||||
|
||||
private:
|
||||
|
|
|
@ -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
|
||||
|
@ -143,10 +143,10 @@ void FileChannel::setProperty(const std::string& name, const std::string& value)
|
|||
{
|
||||
_times = value;
|
||||
|
||||
if(!_rotation.empty())
|
||||
if (!_rotation.empty())
|
||||
setRotation(_rotation);
|
||||
|
||||
if(!_archive.empty())
|
||||
if (!_archive.empty())
|
||||
setArchive(_archive);
|
||||
}
|
||||
else if (name == PROP_PATH)
|
||||
|
@ -225,9 +225,9 @@ void FileChannel::setRotation(const std::string& rotation)
|
|||
RotateStrategy* pStrategy = 0;
|
||||
if ((rotation.find(',') != std::string::npos) || (rotation.find(':') != std::string::npos))
|
||||
{
|
||||
if(_times == "utc")
|
||||
if (_times == "utc")
|
||||
pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
|
||||
else if(_times == "local")
|
||||
else if (_times == "local")
|
||||
pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
|
||||
else
|
||||
throw PropertyNotSupportedException("times", _times);
|
||||
|
@ -271,9 +271,9 @@ void FileChannel::setArchive(const std::string& archive)
|
|||
}
|
||||
else if (archive == "timestamp")
|
||||
{
|
||||
if(_times == "utc")
|
||||
if (_times == "utc")
|
||||
pStrategy = new ArchiveByTimestampStrategy<DateTime>;
|
||||
else if(_times == "local")
|
||||
else if (_times == "local")
|
||||
pStrategy = new ArchiveByTimestampStrategy<LocalDateTime>;
|
||||
else
|
||||
throw PropertyNotSupportedException("times", _times);
|
||||
|
|
Двоичные данные
Foundation/src/MSG00001.bin
Двоичные данные
Foundation/src/MSG00001.bin
Двоичный файл не отображается.
|
@ -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
|
||||
|
@ -137,7 +137,7 @@ const DigestEngine::Digest& SHA1Engine::digest()
|
|||
((BYTE*) _context.data)[count++] = 0x80;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if(count > 56)
|
||||
if (count > 56)
|
||||
{
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset((BYTE*) &_context.data + count, 0, 64 - count);
|
||||
|
|
|
@ -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.
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
AnyTest::AnyTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
AnyTest::AnyTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,21 +70,21 @@ AnyTest::~AnyTest()
|
|||
void AnyTest::testInt()
|
||||
{
|
||||
Any a = 13;
|
||||
poco_assert (a.type() == typeid(int) );
|
||||
int* i = AnyCast < int > (&a);
|
||||
poco_assert ( *i == 13 );
|
||||
assert (a.type() == typeid(int));
|
||||
int* i = AnyCast<int>(&a);
|
||||
assert (*i == 13);
|
||||
Any b = a;
|
||||
poco_assert ( b.type() == typeid(int) );
|
||||
int *cpyI = AnyCast < int > (&b);
|
||||
poco_assert ( *cpyI == *i );
|
||||
assert (b.type() == typeid(int));
|
||||
int *cpyI = AnyCast<int>(&b);
|
||||
assert (*cpyI == *i);
|
||||
*cpyI = 20;
|
||||
poco_assert ( *cpyI != *i );
|
||||
std::string* s = AnyCast < std::string > (&a);
|
||||
poco_assert ( s == NULL);
|
||||
assert (*cpyI != *i);
|
||||
std::string* s = AnyCast<std::string>(&a);
|
||||
assert (s == NULL);
|
||||
|
||||
int tmp = AnyCast < int > (a);
|
||||
int tmp = AnyCast<int>(a);
|
||||
const Any c = a;
|
||||
tmp = AnyCast < int > (a);
|
||||
tmp = AnyCast<int>(a);
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,30 +93,30 @@ 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) );
|
||||
SomeClass str2 = AnyCast < SomeClass > (a);
|
||||
poco_assert ( str == str2 );
|
||||
const SomeClass& strCRef = RefAnyCast < SomeClass > (a);
|
||||
poco_assert ( str == strCRef );
|
||||
SomeClass& strRef = RefAnyCast < SomeClass > (a);
|
||||
poco_assert ( str == strRef );
|
||||
assert (a.type() == typeid(SomeClass));
|
||||
assert (b.type() == typeid(SomeClass));
|
||||
SomeClass str2 = AnyCast<SomeClass>(a);
|
||||
assert (str == str2);
|
||||
const SomeClass& strCRef = RefAnyCast<SomeClass>(a);
|
||||
assert (str == strCRef);
|
||||
SomeClass& strRef = RefAnyCast<SomeClass>(a);
|
||||
assert (str == strRef);
|
||||
}
|
||||
|
||||
|
||||
void AnyTest::testVector()
|
||||
{
|
||||
std::vector < int > tmp;
|
||||
tmp.push_back( 1 );
|
||||
tmp.push_back( 2 );
|
||||
tmp.push_back( 3 );
|
||||
std::vector<int> tmp;
|
||||
tmp.push_back(1);
|
||||
tmp.push_back(2);
|
||||
tmp.push_back(3);
|
||||
Any a = tmp;
|
||||
poco_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);
|
||||
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.
|
||||
|
@ -131,7 +131,7 @@ void AutoPtrTest::testOps()
|
|||
pTO1 = pTO2;
|
||||
pTO2 = pTmp;
|
||||
}
|
||||
assert(pTO1 < pTO2);
|
||||
assert (pTO1 < pTO2);
|
||||
ptr1 = pTO1;
|
||||
AutoPtr<TestObj> ptr2 = pTO2;
|
||||
AutoPtr<TestObj> ptr3 = ptr1;
|
||||
|
|
|
@ -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.
|
||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
|||
#define LARGEINC 100
|
||||
|
||||
|
||||
BasicEventTest::BasicEventTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
BasicEventTest::BasicEventTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,42 +60,42 @@ void BasicEventTest::testNoDelegate()
|
|||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple -= Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
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 );
|
||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex -= Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
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 );
|
||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2 -= Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
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 );
|
||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex -= Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
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 );
|
||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex -= Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void BasicEventTest::testSingleDelegate()
|
||||
|
@ -103,219 +103,219 @@ 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 );
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
ConstSimple += Delegate < BasicEventTest, const int > (this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify ( this, tmp );
|
||||
poco_assert ( _count == 2 );
|
||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assert (_count == 2);
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate < BasicEventTest, Poco::EventArgs* > (this, &BasicEventTest::onComplex);
|
||||
Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 3 );
|
||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
assert (_count == 3);
|
||||
|
||||
Complex2 += Delegate < BasicEventTest, Poco::EventArgs > (this, &BasicEventTest::onComplex2);
|
||||
Complex2.notify ( this, args );
|
||||
poco_assert ( _count == 4 );
|
||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
assert (_count == 4);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate < BasicEventTest, const Poco::EventArgs* > (this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex.notify ( this, pCArgs );
|
||||
poco_assert ( _count == 5 );
|
||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
assert (_count == 5);
|
||||
|
||||
Const2Complex += Delegate < BasicEventTest, const Poco::EventArgs* const > (this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 6 );
|
||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 7 );
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
void BasicEventTest::testDuplicateRegister ()
|
||||
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 );
|
||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testDuplicateUnregister ()
|
||||
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 );
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple); // should work
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testDisabling ()
|
||||
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 );
|
||||
Simple.enable ();
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple.disable();
|
||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testExpire ()
|
||||
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 );
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Poco::Thread::sleep ( 200 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 2 );
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Poco::Thread::sleep( 300 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 3 );
|
||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
void BasicEventTest::testReturnParams ()
|
||||
void BasicEventTest::testReturnParams()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void BasicEventTest::testOverwriteDelegate ()
|
||||
void BasicEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2);
|
||||
// o1 can only have one entry, thus the next line will replace the entry
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
}
|
||||
|
||||
void BasicEventTest::testAsyncNotify ()
|
||||
void BasicEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::BasicEvent < int >* pSimple= new Poco::BasicEvent < int >();
|
||||
(*pSimple) += Delegate < BasicEventTest, int > (this, &BasicEventTest::onAsync);
|
||||
poco_assert ( _count == 0 );
|
||||
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
||||
(*pSimple) += Delegate<BasicEventTest, int>(this, &BasicEventTest::onAsync);
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult < int > retArg = pSimple->notifyAsync ( this, tmp );
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
retArg.wait ();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
}
|
||||
|
||||
void BasicEventTest::onSimple ( const void* pSender, int& i )
|
||||
void BasicEventTest::onSimple(const void* pSender, int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onSimpleOther ( const void* pSender, int& i )
|
||||
void BasicEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
{
|
||||
_count+=100;
|
||||
}
|
||||
|
||||
void BasicEventTest::onConstSimple ( const void* pSender, const int& i )
|
||||
void BasicEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
||||
void BasicEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
||||
void BasicEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
||||
void BasicEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
||||
void BasicEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void BasicEventTest::onAsync ( const void* pSender, int& i )
|
||||
void BasicEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
int BasicEventTest::getCount () const
|
||||
int BasicEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
@ -326,12 +326,12 @@ void BasicEventTest::setUp()
|
|||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Simple.clear ();
|
||||
ConstSimple.clear ();
|
||||
Complex.clear ();
|
||||
Complex2.clear ();
|
||||
ConstComplex.clear ();
|
||||
Const2Complex.clear ();
|
||||
Simple.clear();
|
||||
ConstSimple.clear();
|
||||
Complex.clear();
|
||||
Complex2.clear();
|
||||
ConstComplex.clear();
|
||||
Const2Complex.clear();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
//
|
||||
|
@ -56,14 +56,14 @@ public:
|
|||
|
||||
void testNoDelegate();
|
||||
void testSingleDelegate();
|
||||
void testDuplicateRegister ();
|
||||
void testDuplicateUnregister ();
|
||||
void testDisabling ();
|
||||
void testDuplicateRegister();
|
||||
void testDuplicateUnregister();
|
||||
void testDisabling();
|
||||
void testExpire();
|
||||
void testExpireReRegister();
|
||||
void testReturnParams ();
|
||||
void testOverwriteDelegate ();
|
||||
void testAsyncNotify ();
|
||||
void testReturnParams();
|
||||
void testOverwriteDelegate();
|
||||
void testAsyncNotify();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -71,16 +71,16 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void onSimple ( const void* pSender, int& i );
|
||||
void onSimpleOther ( const void* pSender, int& i );
|
||||
void onConstSimple ( const void* pSender, const int& i );
|
||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
||||
void onAsync ( const void* pSender, int& i );
|
||||
void onSimple(const void* pSender, int& i);
|
||||
void onSimpleOther(const void* pSender, int& i);
|
||||
void onConstSimple(const void* pSender, const int& i);
|
||||
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||
void onAsync(const void* pSender, int& i);
|
||||
|
||||
int getCount () const;
|
||||
int getCount() const;
|
||||
private:
|
||||
int _count;
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
@ -171,7 +171,7 @@ void ClassLoaderTest::testClassLoader2()
|
|||
}
|
||||
|
||||
const AbstractMetaObject<TestPlugin>& meta1 = cl.classFor("PluginC");
|
||||
assert(meta1.isAutoDelete(&(meta1.instance())));
|
||||
assert (meta1.isAutoDelete(&(meta1.instance())));
|
||||
|
||||
// the following must not produce memory leaks
|
||||
const AbstractMetaObject<TestPlugin>& meta2 = cl.classFor("PluginA");
|
||||
|
@ -180,9 +180,9 @@ void ClassLoaderTest::testClassLoader2()
|
|||
|
||||
TestPlugin* pPlugin = meta2.create();
|
||||
meta2.autoDelete(pPlugin);
|
||||
assert(meta2.isAutoDelete(pPlugin));
|
||||
assert (meta2.isAutoDelete(pPlugin));
|
||||
meta2.destroy(pPlugin);
|
||||
assert(!meta2.isAutoDelete(pPlugin));
|
||||
assert (!meta2.isAutoDelete(pPlugin));
|
||||
|
||||
cl.unloadLibrary(path);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -599,18 +599,18 @@ void DateTimeTest::testSwap()
|
|||
void DateTimeTest::testUsage()
|
||||
{
|
||||
DateTime dt1(1776, 7, 4);
|
||||
assert(dt1.year() == 1776);
|
||||
assert(dt1.month() == 7);
|
||||
assert(dt1.day() == 4);
|
||||
assert (dt1.year() == 1776);
|
||||
assert (dt1.month() == 7);
|
||||
assert (dt1.day() == 4);
|
||||
|
||||
DateTime dt2(dt1);
|
||||
dt2 += Timespan(6, 0, 0, 0, 0);
|
||||
assert(dt2.year() == 1776);
|
||||
assert(dt2.month() == 7);
|
||||
assert(dt2.day() == 10);
|
||||
assert (dt2.year() == 1776);
|
||||
assert (dt2.month() == 7);
|
||||
assert (dt2.day() == 10);
|
||||
|
||||
Timespan span = dt2 - dt1;
|
||||
assert(span.days() == 6);
|
||||
assert (span.days() == 6);
|
||||
|
||||
// TODO - When adding months and years we need to be
|
||||
// able to specify the end-end convention.
|
||||
|
@ -662,8 +662,8 @@ void DateTimeTest::testSetYearDay()
|
|||
// TODO - need to be able to assert with the loop counter
|
||||
// but cppUnit is not able to do this.
|
||||
|
||||
assert(r == x);
|
||||
assert(day == X.dayOfYear());
|
||||
assert (r == x);
|
||||
assert (day == X.dayOfYear());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -33,20 +33,20 @@
|
|||
#include "DummyDelegate.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
DummyDelegate::DummyDelegate () {}
|
||||
DummyDelegate::~DummyDelegate () {}
|
||||
DummyDelegate::DummyDelegate() {}
|
||||
DummyDelegate::~DummyDelegate() {}
|
||||
|
||||
void DummyDelegate::onSimple ( const void* pSender, int& i )
|
||||
void DummyDelegate::onSimple(const void* pSender, int& i)
|
||||
{
|
||||
if ( i != 0)
|
||||
if (i != 0)
|
||||
{
|
||||
throw Poco::InvalidArgumentException();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
void DummyDelegate::onSimple2 ( const void* pSender, int& i )
|
||||
void DummyDelegate::onSimple2(const void* pSender, int& i)
|
||||
{
|
||||
if ( i != 1)
|
||||
if (i != 1)
|
||||
{
|
||||
throw Poco::InvalidArgumentException();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// ExpireCacheTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -47,7 +47,7 @@ using namespace Poco;
|
|||
#define DURWAIT 300
|
||||
|
||||
|
||||
ExpireCacheTest::ExpireCacheTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
ExpireCacheTest::ExpireCacheTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,20 +59,20 @@ ExpireCacheTest::~ExpireCacheTest()
|
|||
|
||||
void ExpireCacheTest::testClear()
|
||||
{
|
||||
ExpireCache < int, int > aCache( DURSLEEP );
|
||||
ExpireCache<int, int> aCache(DURSLEEP);
|
||||
aCache.add(1, 2);
|
||||
aCache.add(3, 4);
|
||||
aCache.add(5, 6);
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(1) == 2);
|
||||
assert (*aCache.get(3) == 4);
|
||||
assert (*aCache.get(5) == 6);
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(1));
|
||||
assert (!aCache.has(3));
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,10 +80,10 @@ void ExpireCacheTest::testExpire0()
|
|||
{
|
||||
try
|
||||
{
|
||||
ExpireCache < int, int > aCache( 24 );
|
||||
failmsg ( "cache expire lower than 25 is illegal, test should fail");
|
||||
ExpireCache<int, int> aCache(24);
|
||||
failmsg("cache expire lower than 25 is illegal, test should fail");
|
||||
}
|
||||
catch ( Poco::InvalidArgumentException& )
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -93,63 +93,63 @@ void ExpireCacheTest::testExpireN()
|
|||
{
|
||||
// 3-1 represents the cache sorted by age, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireCache < int, int > aCache( DURSLEEP );
|
||||
ExpireCache<int, int> aCache(DURSLEEP);
|
||||
aCache.add(1, 2); // 1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
SharedPtr < int > tmp = aCache.get( 1 );
|
||||
poco_assert ( tmp );
|
||||
poco_assert ( *tmp == 2 );
|
||||
Thread::sleep( DURWAIT );
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
assert (aCache.has(1));
|
||||
SharedPtr<int> tmp = aCache.get(1);
|
||||
assert (!tmp.isNull());
|
||||
assert (*tmp == 2);
|
||||
Thread::sleep(DURWAIT);
|
||||
assert (!aCache.has(1));
|
||||
|
||||
// tmp must still be valid, access it
|
||||
poco_assert ( *tmp == 2 );
|
||||
tmp = aCache.get( 1 );
|
||||
poco_assert ( !tmp );
|
||||
assert (*tmp == 2);
|
||||
tmp = aCache.get(1);
|
||||
assert (!tmp);
|
||||
|
||||
aCache.add(1, 2); // 1
|
||||
Thread::sleep( DURHALFSLEEP );
|
||||
Thread::sleep(DURHALFSLEEP);
|
||||
aCache.add(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
tmp = aCache.get( 1 );
|
||||
SharedPtr < int > tmp2 = aCache.get( 3 );
|
||||
poco_assert ( *tmp == 2 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
tmp = aCache.get(1);
|
||||
SharedPtr<int> tmp2 = aCache.get(3);
|
||||
assert (*tmp == 2);
|
||||
assert (*tmp2 == 4);
|
||||
|
||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *tmp == 2 ); // 1-3
|
||||
poco_assert ( *tmp2 == 4 ); // 3-1
|
||||
tmp2 = aCache.get( 3 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
tmp = aCache.get( 1 );
|
||||
tmp2 = aCache.get( 3 );
|
||||
poco_assert ( !tmp );
|
||||
poco_assert ( !tmp2 );
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*tmp == 2); // 1-3
|
||||
assert (*tmp2 == 4); // 3-1
|
||||
tmp2 = aCache.get(3);
|
||||
assert (*tmp2 == 4);
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
assert (!aCache.has(3));
|
||||
assert (*tmp2 == 4);
|
||||
tmp = aCache.get(1);
|
||||
tmp2 = aCache.get(3);
|
||||
assert (!tmp);
|
||||
assert (!tmp2);
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear ();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
void ExpireCacheTest::testDuplicateAdd()
|
||||
{
|
||||
ExpireCache < int, int > aCache( DURSLEEP );
|
||||
ExpireCache<int, int> aCache(DURSLEEP);
|
||||
aCache.add(1, 2); // 1
|
||||
poco_assert (aCache.has(1));
|
||||
poco_assert (*aCache.get(1) == 2);
|
||||
assert (aCache.has(1));
|
||||
assert (*aCache.get(1) == 2);
|
||||
aCache.add(1, 3);
|
||||
poco_assert (aCache.has(1));
|
||||
poco_assert (*aCache.get(1) == 3);
|
||||
assert (aCache.has(1));
|
||||
assert (*aCache.get(1) == 3);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -47,7 +47,7 @@ using namespace Poco;
|
|||
#define DURWAIT 300
|
||||
|
||||
|
||||
ExpireLRUCacheTest::ExpireLRUCacheTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
ExpireLRUCacheTest::ExpireLRUCacheTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,20 +59,20 @@ ExpireLRUCacheTest::~ExpireLRUCacheTest()
|
|||
|
||||
void ExpireLRUCacheTest::testClear()
|
||||
{
|
||||
ExpireLRUCache < int, int > aCache( DURSLEEP );
|
||||
ExpireLRUCache<int, int> aCache(DURSLEEP);
|
||||
aCache.add(1, 2);
|
||||
aCache.add(3, 4);
|
||||
aCache.add(5, 6);
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( aCache.has( 5 ) );
|
||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (aCache.has(5));
|
||||
assert (*aCache.get(1) == 2);
|
||||
assert (*aCache.get(3) == 4);
|
||||
assert (*aCache.get(5) == 6);
|
||||
aCache.clear();
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
assert (!aCache.has(1));
|
||||
assert (!aCache.has(3));
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,8 +80,8 @@ void ExpireLRUCacheTest::testExpire0()
|
|||
{
|
||||
try
|
||||
{
|
||||
ExpireLRUCache < int, int > aCache( 1024, 24 );
|
||||
failmsg ( "cache expire lower than 25 is illegal, test should fail");
|
||||
ExpireLRUCache<int, int> aCache(1024, 24);
|
||||
failmsg("cache expire lower than 25 is illegal, test should fail");
|
||||
}
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
|
@ -93,51 +93,51 @@ void ExpireLRUCacheTest::testExpireN()
|
|||
{
|
||||
// 3-1 represents the cache sorted by age, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache < int, int > aCache( 3, DURSLEEP );
|
||||
ExpireLRUCache<int, int> aCache(3, DURSLEEP);
|
||||
aCache.add(1, 2); // 1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
SharedPtr < int > tmp = aCache.get( 1 );
|
||||
poco_assert ( tmp );
|
||||
poco_assert ( *tmp == 2 );
|
||||
Thread::sleep( DURWAIT );
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
assert (aCache.has(1));
|
||||
SharedPtr<int> tmp = aCache.get(1);
|
||||
assert (!tmp.isNull());
|
||||
assert (*tmp == 2);
|
||||
Thread::sleep(DURWAIT);
|
||||
assert (!aCache.has(1));
|
||||
|
||||
// tmp must still be valid, access it
|
||||
poco_assert ( *tmp == 2 );
|
||||
tmp = aCache.get( 1 );
|
||||
poco_assert ( !tmp );
|
||||
assert (*tmp == 2);
|
||||
tmp = aCache.get(1);
|
||||
assert (!tmp);
|
||||
|
||||
aCache.add(1, 2); // 1
|
||||
Thread::sleep( DURHALFSLEEP );
|
||||
Thread::sleep(DURHALFSLEEP);
|
||||
aCache.add(3, 4); // 3-1
|
||||
poco_assert ( aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
tmp = aCache.get( 1 );
|
||||
SharedPtr < int > tmp2 = aCache.get( 3 );
|
||||
poco_assert ( *tmp == 2 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
assert (aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
tmp = aCache.get(1);
|
||||
SharedPtr<int> tmp2 = aCache.get(3);
|
||||
assert (*tmp == 2);
|
||||
assert (*tmp2 == 4);
|
||||
|
||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
||||
poco_assert ( !aCache.has( 1 ) );
|
||||
poco_assert ( aCache.has( 3 ) );
|
||||
poco_assert ( *tmp == 2 ); // 1-3
|
||||
poco_assert ( *tmp2 == 4 ); // 3-1
|
||||
tmp2 = aCache.get( 3 );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
poco_assert ( *tmp2 == 4 );
|
||||
tmp = aCache.get( 1 );
|
||||
tmp2 = aCache.get( 3 );
|
||||
poco_assert ( !tmp );
|
||||
poco_assert ( !tmp2 );
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
assert (!aCache.has(1));
|
||||
assert (aCache.has(3));
|
||||
assert (*tmp == 2); // 1-3
|
||||
assert (*tmp2 == 4); // 3-1
|
||||
tmp2 = aCache.get(3);
|
||||
assert (*tmp2 == 4);
|
||||
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||
assert (!aCache.has(3));
|
||||
assert (*tmp2 == 4);
|
||||
tmp = aCache.get(1);
|
||||
tmp2 = aCache.get(3);
|
||||
assert (!tmp);
|
||||
assert (!tmp2);
|
||||
|
||||
// removing illegal entries should work too
|
||||
aCache.remove(666);
|
||||
|
||||
aCache.clear ();
|
||||
poco_assert ( !aCache.has( 5 ) );
|
||||
poco_assert ( !aCache.has( 3 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@ void ExpireLRUCacheTest::testCacheSize0()
|
|||
// cache size 0 is illegal
|
||||
try
|
||||
{
|
||||
ExpireLRUCache < int, int > aCache( 0 );
|
||||
ExpireLRUCache<int, int> aCache(0);
|
||||
failmsg ("cache size of 0 is illegal, test should fail");
|
||||
}
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
|
@ -157,24 +157,24 @@ void ExpireLRUCacheTest::testCacheSize0()
|
|||
|
||||
void ExpireLRUCacheTest::testCacheSize1()
|
||||
{
|
||||
ExpireLRUCache < int, int > aCache( 1 );
|
||||
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);
|
||||
|
@ -185,39 +185,39 @@ void ExpireLRUCacheTest::testCacheSize2()
|
|||
{
|
||||
// 3-1 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache < int, int > aCache( 2 );
|
||||
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 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,62 +225,62 @@ void ExpireLRUCacheTest::testCacheSizeN()
|
|||
{
|
||||
// 3-1 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
ExpireLRUCache < int, int > aCache( 3 );
|
||||
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 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
void ExpireLRUCacheTest::testDuplicateAdd()
|
||||
{
|
||||
ExpireLRUCache < int, int > aCache( 3 );
|
||||
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.
|
||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
|||
#define LARGEINC 100
|
||||
|
||||
|
||||
FIFOEventTest::FIFOEventTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
FIFOEventTest::FIFOEventTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,42 +60,42 @@ void FIFOEventTest::testNoDelegate()
|
|||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple -= Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
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 );
|
||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex -= Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
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 );
|
||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2 -= Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
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 );
|
||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex -= Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
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 );
|
||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex -= Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testSingleDelegate()
|
||||
|
@ -103,194 +103,194 @@ 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 );
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
ConstSimple += Delegate < FIFOEventTest, const int > (this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify ( this, tmp );
|
||||
poco_assert ( _count == 2 );
|
||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assert (_count == 2);
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += Delegate < FIFOEventTest, Poco::EventArgs* > (this, &FIFOEventTest::onComplex);
|
||||
Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 3 );
|
||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
assert (_count == 3);
|
||||
|
||||
Complex2 += Delegate < FIFOEventTest, Poco::EventArgs > (this, &FIFOEventTest::onComplex2);
|
||||
Complex2.notify ( this, args );
|
||||
poco_assert ( _count == 4 );
|
||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||
Complex2.notify(this, args);
|
||||
assert (_count == 4);
|
||||
|
||||
const EventArgs* pCArgs = &args;
|
||||
ConstComplex += Delegate < FIFOEventTest, const Poco::EventArgs* > (this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex.notify ( this, pCArgs );
|
||||
poco_assert ( _count == 5 );
|
||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
assert (_count == 5);
|
||||
|
||||
Const2Complex += Delegate < FIFOEventTest, const Poco::EventArgs* const > (this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 6 );
|
||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 7 );
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
void FIFOEventTest::testDuplicateRegister ()
|
||||
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 );
|
||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testDuplicateUnregister ()
|
||||
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 );
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple); // should work
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testDisabling ()
|
||||
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 );
|
||||
Simple.enable ();
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple.disable();
|
||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testFIFOOrder ()
|
||||
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);
|
||||
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 );
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple -= Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
||||
Simple -= Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
try
|
||||
{
|
||||
tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
Simple.notify(this, tmp);
|
||||
failmsg ("Notify should not work");
|
||||
}
|
||||
catch ( Poco::InvalidArgumentException& )
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void FIFOEventTest::testFIFOOrderExpire ()
|
||||
void FIFOEventTest::testFIFOOrderExpire()
|
||||
{
|
||||
// expire must not break order!
|
||||
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 );
|
||||
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 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
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);
|
||||
assert (tmp == 2);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2), 5000 );
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
try
|
||||
{
|
||||
tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
Simple.notify(this, tmp);
|
||||
failmsg ("Notify should not work");
|
||||
}
|
||||
catch ( Poco::InvalidArgumentException& )
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FIFOEventTest::testExpire ()
|
||||
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 );
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -298,108 +298,108 @@ 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 );
|
||||
Poco::Thread::sleep ( 200 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 2 );
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Poco::Thread::sleep( 300 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 3 );
|
||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testReturnParams ()
|
||||
void FIFOEventTest::testReturnParams()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testOverwriteDelegate ()
|
||||
void FIFOEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2);
|
||||
// o1 can only have one entry, thus the next line will replace the entry
|
||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
}
|
||||
|
||||
void FIFOEventTest::testAsyncNotify ()
|
||||
void FIFOEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::FIFOEvent < int >* pSimple= new Poco::FIFOEvent < int >();
|
||||
(*pSimple) += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onAsync);
|
||||
poco_assert ( _count == 0 );
|
||||
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
||||
(*pSimple) += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onAsync);
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult < int > retArg = pSimple->notifyAsync ( this, tmp );
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
retArg.wait ();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
}
|
||||
|
||||
void FIFOEventTest::onSimple ( const void* pSender, int& i )
|
||||
void FIFOEventTest::onSimple(const void* pSender, int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onSimpleOther ( const void* pSender, int& i )
|
||||
void FIFOEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
{
|
||||
_count+=100;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onConstSimple ( const void* pSender, const int& i )
|
||||
void FIFOEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
||||
void FIFOEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
||||
void FIFOEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
||||
void FIFOEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
||||
void FIFOEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void FIFOEventTest::onAsync ( const void* pSender, int& i )
|
||||
void FIFOEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
int FIFOEventTest::getCount () const
|
||||
int FIFOEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
@ -410,12 +410,12 @@ void FIFOEventTest::setUp()
|
|||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Simple.clear ();
|
||||
ConstSimple.clear ();
|
||||
Complex.clear ();
|
||||
Complex2.clear ();
|
||||
ConstComplex.clear ();
|
||||
Const2Complex.clear ();
|
||||
Simple.clear();
|
||||
ConstSimple.clear();
|
||||
Complex.clear();
|
||||
Complex2.clear();
|
||||
ConstComplex.clear();
|
||||
Const2Complex.clear();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
@ -56,16 +56,16 @@ public:
|
|||
|
||||
void testNoDelegate();
|
||||
void testSingleDelegate();
|
||||
void testDuplicateRegister ();
|
||||
void testDuplicateUnregister ();
|
||||
void testDisabling ();
|
||||
void testFIFOOrder ();
|
||||
void testFIFOOrderExpire ();
|
||||
void testExpire ();
|
||||
void testDuplicateRegister();
|
||||
void testDuplicateUnregister();
|
||||
void testDisabling();
|
||||
void testFIFOOrder();
|
||||
void testFIFOOrderExpire();
|
||||
void testExpire();
|
||||
void testExpireReRegister();
|
||||
void testReturnParams ();
|
||||
void testOverwriteDelegate ();
|
||||
void testAsyncNotify ();
|
||||
void testReturnParams();
|
||||
void testOverwriteDelegate();
|
||||
void testAsyncNotify();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -73,16 +73,16 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void onSimple ( const void* pSender, int& i );
|
||||
void onSimpleOther ( const void* pSender, int& i );
|
||||
void onConstSimple ( const void* pSender, const int& i );
|
||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
||||
void onAsync ( const void* pSender, int& i );
|
||||
void onSimple(const void* pSender, int& i);
|
||||
void onSimpleOther(const void* pSender, int& i);
|
||||
void onConstSimple(const void* pSender, const int& i);
|
||||
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||
void onAsync(const void* pSender, int& i);
|
||||
|
||||
int getCount () const;
|
||||
int getCount() const;
|
||||
private:
|
||||
int _count;
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
@ -54,31 +54,31 @@ void HashTest::testInsert()
|
|||
{
|
||||
std::string s1("str1");
|
||||
std::string s2("str2");
|
||||
HashTable < std::string, int > hashTable;
|
||||
poco_assert (!hashTable.exists(s1));
|
||||
HashTable<std::string, int> hashTable;
|
||||
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);
|
||||
failmsg ("duplicate insert must fail");
|
||||
}
|
||||
catch(Exception&){}
|
||||
catch (Exception&){}
|
||||
try
|
||||
{
|
||||
hashTable.get(s2);
|
||||
failmsg ("getting a non inserted item must fail");
|
||||
}
|
||||
catch(Exception&){}
|
||||
catch (Exception&){}
|
||||
|
||||
poco_assert (!hashTable.exists(s2));
|
||||
assert (!hashTable.exists(s2));
|
||||
hashTable.insert(s2, 13);
|
||||
poco_assert (hashTable.exists(s2));
|
||||
assert (hashTable.exists(s2));
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,25 +87,25 @@ void HashTest::testUpdate()
|
|||
// add code for second test here
|
||||
std::string s1("str1");
|
||||
std::string s2("str2");
|
||||
HashTable < std::string, int > hashTable;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void HashTest::testOverflow()
|
||||
{
|
||||
HashTable < std::string, int > hashTable(13);
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
hashTable.insert(Poco::NumberFormatter::format(i), i*i);
|
||||
|
@ -114,38 +114,38 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HashTest::testSize()
|
||||
{
|
||||
HashTable < std::string, int > hashTable(13);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
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);
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,19 +165,19 @@ void HashTest::testResize()
|
|||
void HashTest::testStatistic()
|
||||
{
|
||||
double relax = 0.001;
|
||||
HashTable < std::string, int > hashTable(13);
|
||||
poco_assert (hashTable.size() == 0);
|
||||
HashTable<std::string, int> hashTable(13);
|
||||
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.
|
||||
|
@ -41,7 +41,7 @@
|
|||
using namespace Poco;
|
||||
|
||||
|
||||
LRUCacheTest::LRUCacheTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
LRUCacheTest::LRUCacheTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -53,20 +53,20 @@ LRUCacheTest::~LRUCacheTest()
|
|||
|
||||
void LRUCacheTest::testClear()
|
||||
{
|
||||
LRUCache < int, int > aCache( 3 );
|
||||
LRUCache<int, int> aCache(3);
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ void LRUCacheTest::testCacheSize0()
|
|||
// cache size 0 is illegal
|
||||
try
|
||||
{
|
||||
LRUCache < int, int > aCache( 0 );
|
||||
LRUCache<int, int> aCache(0);
|
||||
failmsg ("cache size of 0 is illegal, test should fail");
|
||||
}
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
|
@ -86,24 +86,24 @@ void LRUCacheTest::testCacheSize0()
|
|||
|
||||
void LRUCacheTest::testCacheSize1()
|
||||
{
|
||||
LRUCache < int, int > aCache( 1 );
|
||||
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);
|
||||
|
@ -114,39 +114,39 @@ void LRUCacheTest::testCacheSize2()
|
|||
{
|
||||
// 3-1 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
LRUCache < int, int > aCache( 2 );
|
||||
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 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,62 +154,62 @@ void LRUCacheTest::testCacheSizeN()
|
|||
{
|
||||
// 3-1 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||
// 3-1|5 -> 5 gets removed
|
||||
LRUCache < int, int > aCache( 3 );
|
||||
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 ) );
|
||||
aCache.clear();
|
||||
assert (!aCache.has(5));
|
||||
assert (!aCache.has(3));
|
||||
}
|
||||
|
||||
|
||||
void LRUCacheTest::testDuplicateAdd()
|
||||
{
|
||||
LRUCache < int, int > aCache( 3 );
|
||||
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.
|
||||
|
@ -197,7 +197,7 @@ void LoggerTest::testDump()
|
|||
|
||||
char buffer1[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
|
||||
root.dump("test", buffer1, sizeof(buffer1));
|
||||
assert(pChannel->list().empty());
|
||||
assert (pChannel->list().empty());
|
||||
|
||||
root.setLevel(Message::PRIO_DEBUG);
|
||||
root.dump("test", buffer1, sizeof(buffer1));
|
||||
|
|
|
@ -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.
|
||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
|||
#define LARGEINC 100
|
||||
|
||||
|
||||
PriorityEventTest::PriorityEventTest(const std::string& name ): CppUnit::TestCase(name)
|
||||
PriorityEventTest::PriorityEventTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,42 +60,42 @@ void PriorityEventTest::testNoDelegate()
|
|||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple.notify(this, tmp);
|
||||
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 );
|
||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex.notify(this, pArgs);
|
||||
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 );
|
||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2.notify(this, args);
|
||||
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 );
|
||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
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 );
|
||||
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);
|
||||
assert (_count == 0);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testSingleDelegate()
|
||||
|
@ -103,217 +103,217 @@ void PriorityEventTest::testSingleDelegate()
|
|||
int tmp = 0;
|
||||
EventArgs args;
|
||||
|
||||
poco_assert ( _count == 0 );
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 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 );
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 3);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 3);
|
||||
ConstSimple.notify(this, tmp);
|
||||
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 );
|
||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 3);
|
||||
Complex.notify(this, pArgs);
|
||||
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 );
|
||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 3);
|
||||
Complex2.notify(this, args);
|
||||
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 );
|
||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 3);
|
||||
ConstComplex.notify(this, pCArgs);
|
||||
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 );
|
||||
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);
|
||||
assert (_count == 6);
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify ( this, pArgs );
|
||||
poco_assert ( _count == 7 );
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assert (_count == 7);
|
||||
|
||||
}
|
||||
|
||||
void PriorityEventTest::testDuplicateRegister ()
|
||||
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 );
|
||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimpleOther, 1);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 3 + LARGEINC );
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 2 + LARGEINC);
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3 + LARGEINC);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testDuplicateUnregister ()
|
||||
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 );
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0); // should work
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
|
||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
|
||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testDisabling ()
|
||||
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 );
|
||||
Simple.enable ();
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.disable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple.disable();
|
||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||
Simple.enable();
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testPriorityOrder ()
|
||||
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);
|
||||
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 );
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
|
||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0);
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
|
||||
try
|
||||
{
|
||||
tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
Simple.notify(this, tmp);
|
||||
failmsg ("Notify should not work");
|
||||
}
|
||||
catch ( Poco::InvalidArgumentException& )
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
}
|
||||
|
||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0);
|
||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testPriorityOrderExpire ()
|
||||
void PriorityEventTest::testPriorityOrderExpire()
|
||||
{
|
||||
// expire must not break order!
|
||||
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 );
|
||||
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 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
|
||||
// now start mixing of expire and non expire
|
||||
tmp = 0;
|
||||
Simple += PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1), 500000 );
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 2 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
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);
|
||||
assert (tmp == 2);
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0), 500000 );
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
|
||||
try
|
||||
{
|
||||
tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
Simple.notify(this, tmp);
|
||||
failmsg ("Notify should not work");
|
||||
}
|
||||
catch ( Poco::InvalidArgumentException& )
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
}
|
||||
|
||||
Simple -= PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0), 500000 );
|
||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
|
||||
}
|
||||
|
||||
void PriorityEventTest::testExpire ()
|
||||
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 );
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 1 );
|
||||
Simple -= PriorityExpire < int > (PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 1), 500 );
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(700);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
}
|
||||
|
||||
|
||||
|
@ -321,110 +321,110 @@ 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 );
|
||||
Poco::Thread::sleep ( 200 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 2 );
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 1);
|
||||
Poco::Thread::sleep(200);
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Poco::Thread::sleep( 300 );
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( _count == 3 );
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 600);
|
||||
Poco::Thread::sleep(400);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
Poco::Thread::sleep(300);
|
||||
Simple.notify(this, tmp);
|
||||
assert (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testReturnParams ()
|
||||
void PriorityEventTest::testReturnParams()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
int tmp = 0;
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 1);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testOverwriteDelegate ()
|
||||
void PriorityEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2, 0);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0);
|
||||
// o1 can only have one entry per priority, thus the next line will replace the entry
|
||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
int tmp = 0; // onsimple requires 0 as input
|
||||
Simple.notify ( this, tmp );
|
||||
poco_assert ( tmp == 1 );
|
||||
Simple.notify(this, tmp);
|
||||
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 );
|
||||
Simple -= PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2, 0), 23000);
|
||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
||||
Simple.notify(this, tmp);
|
||||
assert (tmp == 2);
|
||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
||||
}
|
||||
|
||||
void PriorityEventTest::testAsyncNotify ()
|
||||
void PriorityEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::PriorityEvent < int >* pSimple= new Poco::PriorityEvent < int >();
|
||||
(*pSimple) += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onAsync, 0);
|
||||
poco_assert ( _count == 0 );
|
||||
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
||||
(*pSimple) += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onAsync, 0);
|
||||
assert (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult < int > retArg = pSimple->notifyAsync ( this, tmp );
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
poco_assert ( _count == 0 );
|
||||
retArg.wait ();
|
||||
poco_assert ( retArg.data() == tmp );
|
||||
poco_assert ( _count == LARGEINC );
|
||||
assert (_count == 0);
|
||||
retArg.wait();
|
||||
assert (retArg.data() == tmp);
|
||||
assert (_count == LARGEINC);
|
||||
|
||||
}
|
||||
|
||||
void PriorityEventTest::onSimple ( const void* pSender, int& i )
|
||||
void PriorityEventTest::onSimple(const void* pSender, int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onSimpleOther ( const void* pSender, int& i )
|
||||
void PriorityEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
{
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onConstSimple ( const void* pSender, const int& i )
|
||||
void PriorityEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
||||
void PriorityEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
||||
void PriorityEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
||||
void PriorityEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
||||
void PriorityEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
void PriorityEventTest::onAsync ( const void* pSender, int& i )
|
||||
void PriorityEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep ( 700 );
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
int PriorityEventTest::getCount () const
|
||||
int PriorityEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
@ -435,12 +435,12 @@ void PriorityEventTest::setUp()
|
|||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Simple.clear ();
|
||||
ConstSimple.clear ();
|
||||
Complex.clear ();
|
||||
Complex2.clear ();
|
||||
ConstComplex.clear ();
|
||||
Const2Complex.clear ();
|
||||
Simple.clear();
|
||||
ConstSimple.clear();
|
||||
Complex.clear();
|
||||
Complex2.clear();
|
||||
ConstComplex.clear();
|
||||
Const2Complex.clear();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
@ -56,16 +56,16 @@ public:
|
|||
|
||||
void testNoDelegate();
|
||||
void testSingleDelegate();
|
||||
void testDuplicateRegister ();
|
||||
void testDuplicateUnregister ();
|
||||
void testDisabling ();
|
||||
void testPriorityOrder ();
|
||||
void testPriorityOrderExpire ();
|
||||
void testExpire ();
|
||||
void testDuplicateRegister();
|
||||
void testDuplicateUnregister();
|
||||
void testDisabling();
|
||||
void testPriorityOrder();
|
||||
void testPriorityOrderExpire();
|
||||
void testExpire();
|
||||
void testExpireReRegister();
|
||||
void testReturnParams ();
|
||||
void testOverwriteDelegate ();
|
||||
void testAsyncNotify ();
|
||||
void testReturnParams();
|
||||
void testOverwriteDelegate();
|
||||
void testAsyncNotify();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -73,16 +73,16 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void onSimple ( const void* pSender, int& i );
|
||||
void onSimpleOther ( const void* pSender, int& i );
|
||||
void onConstSimple ( const void* pSender, const int& i );
|
||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
||||
void onAsync ( const void* pSender, int& i );
|
||||
void onSimple(const void* pSender, int& i);
|
||||
void onSimpleOther(const void* pSender, int& i);
|
||||
void onConstSimple(const void* pSender, const int& i);
|
||||
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||
void onAsync(const void* pSender, int& i);
|
||||
|
||||
int getCount () const;
|
||||
int getCount() const;
|
||||
private:
|
||||
int _count;
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
@ -112,7 +112,7 @@ void SharedPtrTest::testSharedPtr()
|
|||
pTO1 = pTO2;
|
||||
pTO2 = pTmp;
|
||||
}
|
||||
assert(pTO1 < pTO2);
|
||||
assert (pTO1 < pTO2);
|
||||
ptr1 = pTO1;
|
||||
SharedPtr<TestObject> ptr2 = pTO2;
|
||||
SharedPtr<TestObject> ptr3 = ptr1;
|
||||
|
@ -181,12 +181,12 @@ void SharedPtrTest::testImplicitCast()
|
|||
{
|
||||
{
|
||||
// null assign test
|
||||
SharedPtr < DerivedObject > ptr2;
|
||||
SharedPtr<DerivedObject> ptr2;
|
||||
assertNull(ptr2.get());
|
||||
SharedPtr<TestObject> ptr1 = ptr2;
|
||||
}
|
||||
{
|
||||
SharedPtr < DerivedObject > ptr2(new DerivedObject("test", 666));
|
||||
SharedPtr<DerivedObject> ptr2(new DerivedObject("test", 666));
|
||||
assert (TestObject::count() == 1);
|
||||
SharedPtr<TestObject> ptr1 = ptr2;
|
||||
assert (TestObject::count() == 1);
|
||||
|
@ -201,7 +201,7 @@ void SharedPtrTest::testImplicitCast()
|
|||
void SharedPtrTest::testExplicitCast()
|
||||
{
|
||||
SharedPtr<TestObject> ptr1 = new DerivedObject("test", 666);
|
||||
SharedPtr < DerivedObject > ptr2 = ptr1.cast<DerivedObject>();
|
||||
SharedPtr<DerivedObject> ptr2 = ptr1.cast<DerivedObject>();
|
||||
assert (ptr2.get() != 0);
|
||||
|
||||
// cast the other way round must fail
|
||||
|
|
|
@ -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); \
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.2.3 (2006-09-14)
|
||||
1.2.4 (2006-09-29)
|
||||
|
|
|
@ -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
|
||||
|
@ -177,7 +183,19 @@ public:
|
|||
/// or null if such an element does not exist.
|
||||
///
|
||||
/// 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;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче