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.
|
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)
|
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
|
// AbstractCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -70,12 +70,12 @@ public:
|
||||||
typedef typename DataHolder::const_iterator ConstIterator;
|
typedef typename DataHolder::const_iterator ConstIterator;
|
||||||
typedef std::set<TKey> KeySet;
|
typedef std::set<TKey> KeySet;
|
||||||
|
|
||||||
AbstractCache()
|
AbstractCache()
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractCache(const TStrategy& strat):_strategy(strat)
|
AbstractCache(const TStrategy& strat): _strategy(strat)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
{
|
{
|
||||||
uninitialize();
|
uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const TKey& key, const TValue& val)
|
void add(const TKey& key, const TValue& val)
|
||||||
/// Adds the key value pair to the cache.
|
/// Adds the key value pair to the cache.
|
||||||
/// If for the key already an entry exists, it will be overwritten.
|
/// If for the key already an entry exists, it will be overwritten.
|
||||||
|
@ -92,7 +92,7 @@ public:
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doAdd(key, val);
|
doAdd(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const TKey& key)
|
void remove(const TKey& key)
|
||||||
/// Removes an entry from the cache. If the entry is not found,
|
/// Removes an entry from the cache. If the entry is not found,
|
||||||
/// the remove is ignored.
|
/// the remove is ignored.
|
||||||
|
@ -100,13 +100,13 @@ public:
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doRemove(key);
|
doRemove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has(const TKey& key) const
|
bool has(const TKey& key) const
|
||||||
/// Returns true if the cache contains a value for the key.
|
/// Returns true if the cache contains a value for the key.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return doHas(key);
|
return doHas(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPtr<TValue> get(const TKey& key)
|
SharedPtr<TValue> get(const TKey& key)
|
||||||
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
|
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
|
||||||
|
@ -116,7 +116,7 @@ public:
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return doGet (key);
|
return doGet (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
/// Removes all elements from the cache.
|
/// Removes all elements from the cache.
|
||||||
{
|
{
|
||||||
|
@ -138,7 +138,7 @@ protected:
|
||||||
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
||||||
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitialize()
|
void uninitialize()
|
||||||
/// Reverts event registration.
|
/// Reverts event registration.
|
||||||
{
|
{
|
||||||
|
@ -165,7 +165,7 @@ protected:
|
||||||
|
|
||||||
doReplace();
|
doReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRemove(const TKey& key)
|
void doRemove(const TKey& key)
|
||||||
/// Removes an entry from the cache. If the entry is not found
|
/// Removes an entry from the cache. If the entry is not found
|
||||||
/// the remove is ignored.
|
/// the remove is ignored.
|
||||||
|
@ -173,7 +173,7 @@ protected:
|
||||||
Remove.notify(this, key);
|
Remove.notify(this, key);
|
||||||
_data.erase(key);
|
_data.erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doHas(const TKey& key) const
|
bool doHas(const TKey& key) const
|
||||||
/// Returns true if the cache contains a value for the key
|
/// Returns true if the cache contains a value for the key
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ protected:
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doClear()
|
void doClear()
|
||||||
{
|
{
|
||||||
static EventArgs _emptyArgs;
|
static EventArgs _emptyArgs;
|
||||||
|
@ -244,7 +244,6 @@ protected:
|
||||||
mutable DataHolder _data;
|
mutable DataHolder _data;
|
||||||
mutable FastMutex _mutex;
|
mutable FastMutex _mutex;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractCache(const AbstractCache& aCache);
|
AbstractCache(const AbstractCache& aCache);
|
||||||
AbstractCache& operator = (const AbstractCache& aCache);
|
AbstractCache& operator = (const AbstractCache& aCache);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// AbstractStrategy.h
|
// AbstractStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -53,8 +53,8 @@ class AbstractStrategy
|
||||||
/// An AbstractStrategy is the interface for all strategies.
|
/// An AbstractStrategy is the interface for all strategies.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractStrategy()
|
AbstractStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractStrategy()
|
virtual ~AbstractStrategy()
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
virtual void onGet(const void* pSender, const TKey& key) = 0;
|
virtual void onGet(const void* pSender, const TKey& key) = 0;
|
||||||
/// Informs the strategy that a read-access happens to an element.
|
/// Informs the strategy that a read-access happens to an element.
|
||||||
|
|
||||||
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
|
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
|
||||||
/// Removes all elements from the cache.
|
/// Removes all elements from the cache.
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// AutoPtr.h
|
// AutoPtr.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -151,18 +151,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr < Other > cast()
|
AutoPtr<Other> cast()
|
||||||
/// Casts the AutoPtr via a dynamic cast to the given type.
|
/// Casts the AutoPtr via a dynamic cast to the given type.
|
||||||
/// Returns an AutoPtr containing NULL if the cast fails.
|
/// Returns an AutoPtr containing NULL if the cast fails.
|
||||||
/// Example: (assume class Sub: public Super)
|
/// Example: (assume class Sub: public Super)
|
||||||
/// AutoPtr < Super > super(new Sub());
|
/// AutoPtr<Super> super(new Sub());
|
||||||
/// AutoPtr < Sub > sub = super.cast<Sub>();
|
/// AutoPtr<Sub> sub = super.cast<Sub>();
|
||||||
/// poco_assert (sub.get());
|
/// poco_assert (sub.get());
|
||||||
{
|
{
|
||||||
Other* pOther = dynamic_cast <Other*>(_ptr);
|
Other* pOther = dynamic_cast <Other*>(_ptr);
|
||||||
if (pOther)
|
if (pOther)
|
||||||
pOther->duplicate();
|
pOther->duplicate();
|
||||||
return AutoPtr < Other > (pOther);
|
return AutoPtr<Other>(pOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
C* operator -> ()
|
C* operator -> ()
|
||||||
|
@ -201,6 +201,11 @@ public:
|
||||||
{
|
{
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNull() const
|
||||||
|
{
|
||||||
|
return _ptr == 0;
|
||||||
|
}
|
||||||
|
|
||||||
operator C* ()
|
operator C* ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ExpireCache.h
|
// ExpireCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -48,7 +48,7 @@ namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
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)
|
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
|
||||||
/// Be careful when using an ExpireCache. A cache is often used
|
/// 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
|
/// like cache.has(x) followed by cache.get x). Note that it could happen
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ExpireLRUCache.h
|
// ExpireLRUCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -52,7 +52,7 @@ namespace Poco {
|
||||||
template <
|
template <
|
||||||
class TKey,
|
class TKey,
|
||||||
class TValue
|
class TValue
|
||||||
>
|
>
|
||||||
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
|
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
|
||||||
/// An ExpireLRUCache combines LUR caching and time based expire caching.
|
/// An ExpireLRUCache combines LUR caching and time based expire caching.
|
||||||
/// It cache entries for a fixed time period (per default 10 minutes)
|
/// 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));
|
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ExpireLRUCache()
|
~ExpireLRUCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExpireLRUCache(const ExpireLRUCache& aCache);
|
ExpireLRUCache(const ExpireLRUCache& aCache);
|
||||||
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
|
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ExpireStrategy.h
|
// ExpireStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -56,15 +56,15 @@ namespace Poco {
|
||||||
template <
|
template <
|
||||||
class TKey,
|
class TKey,
|
||||||
class TValue
|
class TValue
|
||||||
>
|
>
|
||||||
class ExpireStrategy: public AbstractStrategy<TKey, 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:
|
public:
|
||||||
typedef std::multimap<Timestamp, TKey> TimeIndex;
|
typedef std::multimap<Timestamp, TKey> TimeIndex;
|
||||||
typedef typename TimeIndex::iterator IndexIterator;
|
typedef typename TimeIndex::iterator IndexIterator;
|
||||||
typedef typename TimeIndex::const_iterator ConstIndexIterator;
|
typedef typename TimeIndex::const_iterator ConstIndexIterator;
|
||||||
typedef std::map<TKey, IndexIterator> Keys;
|
typedef std::map<TKey, IndexIterator> Keys;
|
||||||
typedef typename Keys::iterator Iterator;
|
typedef typename Keys::iterator Iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ExpireStrategy()
|
~ExpireStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
{
|
{
|
||||||
Timestamp now;
|
Timestamp now;
|
||||||
IndexIterator it = _keyIndex.insert(std::make_pair(now, args.key()));
|
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)
|
if (!stat.second)
|
||||||
{
|
{
|
||||||
_keyIndex.erase(stat.first->second);
|
_keyIndex.erase(stat.first->second);
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
void onRemove(const void*, const TKey& key)
|
void onRemove(const void*, const TKey& key)
|
||||||
{
|
{
|
||||||
Iterator it = _keys.find(key);
|
Iterator it = _keys.find(key);
|
||||||
if (it != _keys.end ())
|
if (it != _keys.end())
|
||||||
{
|
{
|
||||||
_keyIndex.erase(it->second);
|
_keyIndex.erase(it->second);
|
||||||
_keys.erase(it);
|
_keys.erase(it);
|
||||||
|
@ -111,11 +111,11 @@ public:
|
||||||
_keys.clear();
|
_keys.clear();
|
||||||
_keyIndex.clear();
|
_keyIndex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onIsValid(const void*, ValidArgs<TKey>& args)
|
void onIsValid(const void*, ValidArgs<TKey>& args)
|
||||||
{
|
{
|
||||||
Iterator it = _keys.find(args.key());
|
Iterator it = _keys.find(args.key());
|
||||||
if (it != _keys.end ())
|
if (it != _keys.end())
|
||||||
{
|
{
|
||||||
if (it->second->first.isElapsed(_expireTime))
|
if (it->second->first.isElapsed(_expireTime))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Foundation.h
|
// Foundation.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -83,6 +83,7 @@
|
||||||
//
|
//
|
||||||
// Include platform-specific definitions
|
// Include platform-specific definitions
|
||||||
//
|
//
|
||||||
|
#include "Poco/Platform.h"
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include "Poco/Platform_WIN32.h"
|
#include "Poco/Platform_WIN32.h"
|
||||||
#elif defined(__VMS)
|
#elif defined(__VMS)
|
||||||
|
@ -95,7 +96,6 @@
|
||||||
//
|
//
|
||||||
// Pull in basic definitions
|
// Pull in basic definitions
|
||||||
//
|
//
|
||||||
#include "Poco/Platform.h"
|
|
||||||
#include "Poco/Bugcheck.h"
|
#include "Poco/Bugcheck.h"
|
||||||
#include "Poco/Types.h"
|
#include "Poco/Types.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// HashTable.h
|
// HashTable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!_entries[hsh])
|
if (!_entries[hsh])
|
||||||
_entries[hsh] = new HashEntryMap();
|
_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)
|
if (res.second == false)
|
||||||
res.first->second = value;
|
res.first->second = value;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// KeyValueArgs.h
|
// KeyValueArgs.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const TKey& key() const
|
const TKey& key() const
|
||||||
/// Returns a reference to the key,
|
/// Returns a reference to the key,
|
||||||
{
|
{
|
||||||
return _key;
|
return _key;
|
||||||
|
@ -79,7 +79,7 @@ public:
|
||||||
{
|
{
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TKey& _key;
|
const TKey& _key;
|
||||||
const TValue& _value;
|
const TValue& _value;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// LRUCache.h
|
// LRUCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -51,14 +51,13 @@ template <class TKey, class TValue>
|
||||||
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
|
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
|
||||||
/// An LRUCache is the interface of all caches.
|
/// An LRUCache is the interface of all caches.
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LRUCache(long size = 1024):
|
LRUCache(long size = 1024):
|
||||||
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
|
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~LRUCache()
|
~LRUCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// LRUStrategy.h
|
// LRUStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <class TKey, class TValue>
|
||||||
class LRUStrategy: public AbstractStrategy<TKey, TValue>
|
class LRUStrategy: public AbstractStrategy<TKey, TValue>
|
||||||
/// An LRUStrategy implements least recently used cache replacement.
|
/// An LRUStrategy implements least recently used cache replacement.
|
||||||
{
|
{
|
||||||
|
@ -71,14 +71,14 @@ public:
|
||||||
if (_size < 1) throw InvalidArgumentException("size must be > 0");
|
if (_size < 1) throw InvalidArgumentException("size must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~LRUStrategy()
|
~LRUStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
|
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
|
||||||
{
|
{
|
||||||
_keys.push_front(args.key());
|
_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)
|
if (!stat.second)
|
||||||
{
|
{
|
||||||
stat.first->second = _keys.begin();
|
stat.first->second = _keys.begin();
|
||||||
|
@ -135,7 +135,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t diff = curSize - _size;
|
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;
|
size_t i = 0;
|
||||||
|
|
||||||
while (i++ < diff)
|
while (i++ < diff)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// SharedPtr.h
|
// SharedPtr.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#2 $
|
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -166,18 +166,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
SharedPtr < Other > cast()
|
SharedPtr<Other> cast()
|
||||||
/// Casts the SharedPtr via a dynamic cast to the given type.
|
/// Casts the SharedPtr via a dynamic cast to the given type.
|
||||||
/// Returns an SharedPtr containing NULL if the cast fails.
|
/// Returns an SharedPtr containing NULL if the cast fails.
|
||||||
/// Example: (assume class Sub: public Super)
|
/// Example: (assume class Sub: public Super)
|
||||||
/// SharedPtr < Super > super(new Sub());
|
/// SharedPtr<Super> super(new Sub());
|
||||||
/// SharedPtr < Sub > sub = super.cast<Sub>();
|
/// SharedPtr<Sub> sub = super.cast<Sub>();
|
||||||
/// poco_assert (sub.get());
|
/// poco_assert (sub.get());
|
||||||
{
|
{
|
||||||
Other* pOther = dynamic_cast <Other*>(_ptr);
|
Other* pOther = dynamic_cast <Other*>(_ptr);
|
||||||
if (pOther)
|
if (pOther)
|
||||||
return SharedPtr < Other > (_pCounter, pOther);
|
return SharedPtr<Other> (_pCounter, pOther);
|
||||||
return SharedPtr < Other > ();
|
return SharedPtr<Other>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(SharedPtr& ptr)
|
void swap(SharedPtr& ptr)
|
||||||
|
@ -212,7 +212,7 @@ public:
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{
|
{
|
||||||
return (_ptr == 0);
|
return _ptr == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator C* ()
|
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
|
/// for cast operation
|
||||||
{
|
{
|
||||||
poco_assert_dbg (_pCounter);
|
poco_assert_dbg (_pCounter);
|
||||||
_pCounter->duplicate();
|
_pCounter->duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReferenceCounter* _pCounter;
|
ReferenceCounter* _pCounter;
|
||||||
C* _ptr;
|
C* _ptr;
|
||||||
|
|
||||||
template < class Other > friend class SharedPtr;
|
template<class Other> friend class SharedPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// SimpleHashTable.h
|
// SimpleHashTable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -191,7 +191,7 @@ public:
|
||||||
UInt32 origHash = hsh;
|
UInt32 origHash = hsh;
|
||||||
while (_entries[hsh % _maxCapacity])
|
while (_entries[hsh % _maxCapacity])
|
||||||
{
|
{
|
||||||
if(_entries[hsh % _maxCapacity]->key == key)
|
if (_entries[hsh % _maxCapacity]->key == key)
|
||||||
{
|
{
|
||||||
_entries[hsh % _maxCapacity]->value = value;
|
_entries[hsh % _maxCapacity]->value = value;
|
||||||
return;
|
return;
|
||||||
|
@ -225,7 +225,7 @@ public:
|
||||||
{
|
{
|
||||||
if (_entries[hsh % _maxCapacity])
|
if (_entries[hsh % _maxCapacity])
|
||||||
{
|
{
|
||||||
if(_entries[hsh % _maxCapacity]->key == key)
|
if (_entries[hsh % _maxCapacity]->key == key)
|
||||||
{
|
{
|
||||||
return _entries[hsh % _maxCapacity]->value;
|
return _entries[hsh % _maxCapacity]->value;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ public:
|
||||||
{
|
{
|
||||||
if (_entries[hsh % _maxCapacity])
|
if (_entries[hsh % _maxCapacity])
|
||||||
{
|
{
|
||||||
if(_entries[hsh % _maxCapacity]->key == key)
|
if (_entries[hsh % _maxCapacity]->key == key)
|
||||||
{
|
{
|
||||||
return _entries[hsh % _maxCapacity]->key;
|
return _entries[hsh % _maxCapacity]->key;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ public:
|
||||||
{
|
{
|
||||||
if (_entries[hsh % _maxCapacity])
|
if (_entries[hsh % _maxCapacity])
|
||||||
{
|
{
|
||||||
if(_entries[hsh % _maxCapacity]->key == key)
|
if (_entries[hsh % _maxCapacity]->key == key)
|
||||||
{
|
{
|
||||||
v = _entries[hsh % _maxCapacity]->value;
|
v = _entries[hsh % _maxCapacity]->value;
|
||||||
return true;
|
return true;
|
||||||
|
@ -304,7 +304,7 @@ public:
|
||||||
{
|
{
|
||||||
if (_entries[hsh % _maxCapacity])
|
if (_entries[hsh % _maxCapacity])
|
||||||
{
|
{
|
||||||
if(_entries[hsh % _maxCapacity]->key == key)
|
if (_entries[hsh % _maxCapacity]->key == key)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// StrategyCollection.h
|
// StrategyCollection.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -60,14 +60,14 @@ public:
|
||||||
typedef typename Strategies::const_iterator ConstIterator;
|
typedef typename Strategies::const_iterator ConstIterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StrategyCollection()
|
StrategyCollection()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~StrategyCollection()
|
~StrategyCollection()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushBack(AbstractStrategy<TKey, TValue>* pStrat)
|
void pushBack(AbstractStrategy<TKey, TValue>* pStrat)
|
||||||
/// Adds an AbstractStrategy to the collection. Class takes ownership of pointer
|
/// Adds an AbstractStrategy to the collection. Class takes ownership of pointer
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
/// Removes the last added AbstractStrategy from the collection.
|
/// Removes the last added AbstractStrategy from the collection.
|
||||||
{
|
{
|
||||||
_strategies.pop_back();
|
_strategies.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key)
|
void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key)
|
||||||
/// Adds the key to the strategy.
|
/// Adds the key to the strategy.
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
(*it)->onRemove(pSender, key);
|
(*it)->onRemove(pSender, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGet(const void* pSender, const TKey& key)
|
void onGet(const void* pSender, const TKey& key)
|
||||||
{
|
{
|
||||||
Iterator it = _strategies.begin();
|
Iterator it = _strategies.begin();
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
(*it)->onGet(pSender, key);
|
(*it)->onGet(pSender, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClear(const void* pSender, const EventArgs& args)
|
void onClear(const void* pSender, const EventArgs& args)
|
||||||
{
|
{
|
||||||
Iterator it = _strategies.begin();
|
Iterator it = _strategies.begin();
|
||||||
|
@ -128,7 +128,7 @@ public:
|
||||||
{
|
{
|
||||||
Iterator it = _strategies.begin();
|
Iterator it = _strategies.begin();
|
||||||
Iterator endIt = _strategies.end();
|
Iterator endIt = _strategies.end();
|
||||||
for (; it != endIt && key.isValid (); ++it)
|
for (; it != endIt && key.isValid(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->onIsValid(pSender, key);
|
(*it)->onIsValid(pSender, key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Timestamp.h
|
// Timestamp.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
|
@ -80,6 +80,7 @@ public:
|
||||||
/// Swaps the Timestamp with another one.
|
/// Swaps the Timestamp with another one.
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
/// Updates the Timestamp with the current time.
|
||||||
|
|
||||||
bool operator == (const Timestamp& ts) const;
|
bool operator == (const Timestamp& ts) const;
|
||||||
bool operator != (const Timestamp& ts) const;
|
bool operator != (const Timestamp& ts) const;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ValidArgs.h
|
// ValidArgs.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#1 $
|
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey>
|
template <class TKey>
|
||||||
class ValidArgs
|
class ValidArgs
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TKey& _key;
|
const TKey& _key;
|
||||||
bool _isValid;
|
bool _isValid;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// FileChannel.cpp
|
// FileChannel.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/src/FileChannel.cpp#1 $
|
// $Id: //poco/1.2/Foundation/src/FileChannel.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
|
@ -143,10 +143,10 @@ void FileChannel::setProperty(const std::string& name, const std::string& value)
|
||||||
{
|
{
|
||||||
_times = value;
|
_times = value;
|
||||||
|
|
||||||
if(!_rotation.empty())
|
if (!_rotation.empty())
|
||||||
setRotation(_rotation);
|
setRotation(_rotation);
|
||||||
|
|
||||||
if(!_archive.empty())
|
if (!_archive.empty())
|
||||||
setArchive(_archive);
|
setArchive(_archive);
|
||||||
}
|
}
|
||||||
else if (name == PROP_PATH)
|
else if (name == PROP_PATH)
|
||||||
|
@ -225,9 +225,9 @@ void FileChannel::setRotation(const std::string& rotation)
|
||||||
RotateStrategy* pStrategy = 0;
|
RotateStrategy* pStrategy = 0;
|
||||||
if ((rotation.find(',') != std::string::npos) || (rotation.find(':') != std::string::npos))
|
if ((rotation.find(',') != std::string::npos) || (rotation.find(':') != std::string::npos))
|
||||||
{
|
{
|
||||||
if(_times == "utc")
|
if (_times == "utc")
|
||||||
pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
|
pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
|
||||||
else if(_times == "local")
|
else if (_times == "local")
|
||||||
pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
|
pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
|
||||||
else
|
else
|
||||||
throw PropertyNotSupportedException("times", _times);
|
throw PropertyNotSupportedException("times", _times);
|
||||||
|
@ -271,9 +271,9 @@ void FileChannel::setArchive(const std::string& archive)
|
||||||
}
|
}
|
||||||
else if (archive == "timestamp")
|
else if (archive == "timestamp")
|
||||||
{
|
{
|
||||||
if(_times == "utc")
|
if (_times == "utc")
|
||||||
pStrategy = new ArchiveByTimestampStrategy<DateTime>;
|
pStrategy = new ArchiveByTimestampStrategy<DateTime>;
|
||||||
else if(_times == "local")
|
else if (_times == "local")
|
||||||
pStrategy = new ArchiveByTimestampStrategy<LocalDateTime>;
|
pStrategy = new ArchiveByTimestampStrategy<LocalDateTime>;
|
||||||
else
|
else
|
||||||
throw PropertyNotSupportedException("times", _times);
|
throw PropertyNotSupportedException("times", _times);
|
||||||
|
|
Двоичные данные
Foundation/src/MSG00001.bin
Двоичные данные
Foundation/src/MSG00001.bin
Двоичный файл не отображается.
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// SHA1Engine.cpp
|
// SHA1Engine.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/Foundation/src/SHA1Engine.cpp#1 $
|
// $Id: //poco/1.2/Foundation/src/SHA1Engine.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Crypt
|
// Package: Crypt
|
||||||
|
@ -137,7 +137,7 @@ const DigestEngine::Digest& SHA1Engine::digest()
|
||||||
((BYTE*) _context.data)[count++] = 0x80;
|
((BYTE*) _context.data)[count++] = 0x80;
|
||||||
|
|
||||||
/* Pad out to 56 mod 64 */
|
/* Pad out to 56 mod 64 */
|
||||||
if(count > 56)
|
if (count > 56)
|
||||||
{
|
{
|
||||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||||
memset((BYTE*) &_context.data + count, 0, 64 - count);
|
memset((BYTE*) &_context.data + count, 0, 64 - count);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// pocomsg.mc[.h]
|
// 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.
|
// The Poco message source/header file.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// AnyTest.cpp
|
// 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.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// 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()
|
void AnyTest::testInt()
|
||||||
{
|
{
|
||||||
Any a = 13;
|
Any a = 13;
|
||||||
poco_assert (a.type() == typeid(int) );
|
assert (a.type() == typeid(int));
|
||||||
int* i = AnyCast < int > (&a);
|
int* i = AnyCast<int>(&a);
|
||||||
poco_assert ( *i == 13 );
|
assert (*i == 13);
|
||||||
Any b = a;
|
Any b = a;
|
||||||
poco_assert ( b.type() == typeid(int) );
|
assert (b.type() == typeid(int));
|
||||||
int *cpyI = AnyCast < int > (&b);
|
int *cpyI = AnyCast<int>(&b);
|
||||||
poco_assert ( *cpyI == *i );
|
assert (*cpyI == *i);
|
||||||
*cpyI = 20;
|
*cpyI = 20;
|
||||||
poco_assert ( *cpyI != *i );
|
assert (*cpyI != *i);
|
||||||
std::string* s = AnyCast < std::string > (&a);
|
std::string* s = AnyCast<std::string>(&a);
|
||||||
poco_assert ( s == NULL);
|
assert (s == NULL);
|
||||||
|
|
||||||
int tmp = AnyCast < int > (a);
|
int tmp = AnyCast<int>(a);
|
||||||
const Any c = 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"));
|
SomeClass str(13,std::string("hello"));
|
||||||
Any a = str;
|
Any a = str;
|
||||||
Any b = a;
|
Any b = a;
|
||||||
poco_assert (a.type() == typeid(SomeClass) );
|
assert (a.type() == typeid(SomeClass));
|
||||||
poco_assert (b.type() == typeid(SomeClass) );
|
assert (b.type() == typeid(SomeClass));
|
||||||
SomeClass str2 = AnyCast < SomeClass > (a);
|
SomeClass str2 = AnyCast<SomeClass>(a);
|
||||||
poco_assert ( str == str2 );
|
assert (str == str2);
|
||||||
const SomeClass& strCRef = RefAnyCast < SomeClass > (a);
|
const SomeClass& strCRef = RefAnyCast<SomeClass>(a);
|
||||||
poco_assert ( str == strCRef );
|
assert (str == strCRef);
|
||||||
SomeClass& strRef = RefAnyCast < SomeClass > (a);
|
SomeClass& strRef = RefAnyCast<SomeClass>(a);
|
||||||
poco_assert ( str == strRef );
|
assert (str == strRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AnyTest::testVector()
|
void AnyTest::testVector()
|
||||||
{
|
{
|
||||||
std::vector < int > tmp;
|
std::vector<int> tmp;
|
||||||
tmp.push_back( 1 );
|
tmp.push_back(1);
|
||||||
tmp.push_back( 2 );
|
tmp.push_back(2);
|
||||||
tmp.push_back( 3 );
|
tmp.push_back(3);
|
||||||
Any a = tmp;
|
Any a = tmp;
|
||||||
poco_assert (a.type() == typeid(std::vector < int >) );
|
assert (a.type() == typeid(std::vector<int>));
|
||||||
std::vector < int > tmp2 = AnyCast < std::vector < int > >(a);
|
std::vector<int>tmp2 = AnyCast<std::vector<int> >(a);
|
||||||
const std::vector < int >& vecCRef = RefAnyCast < std::vector < int > >(a);
|
const std::vector<int >& vecCRef = RefAnyCast<std::vector<int> >(a);
|
||||||
std::vector < int >& vecRef = RefAnyCast < std::vector < int > >(a);
|
std::vector<int >& vecRef = RefAnyCast<std::vector<int> >(a);
|
||||||
vecRef[0] = 0;
|
vecRef[0] = 0;
|
||||||
poco_assert( vecRef[0] == vecCRef[0] );
|
assert (vecRef[0] == vecCRef[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// AutoPtrTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -131,7 +131,7 @@ void AutoPtrTest::testOps()
|
||||||
pTO1 = pTO2;
|
pTO1 = pTO2;
|
||||||
pTO2 = pTmp;
|
pTO2 = pTmp;
|
||||||
}
|
}
|
||||||
assert(pTO1 < pTO2);
|
assert (pTO1 < pTO2);
|
||||||
ptr1 = pTO1;
|
ptr1 = pTO1;
|
||||||
AutoPtr<TestObj> ptr2 = pTO2;
|
AutoPtr<TestObj> ptr2 = pTO2;
|
||||||
AutoPtr<TestObj> ptr3 = ptr1;
|
AutoPtr<TestObj> ptr3 = ptr1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// BasicEventTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
||||||
#define LARGEINC 100
|
#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;
|
int tmp = 0;
|
||||||
EventArgs args;
|
EventArgs args;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += Delegate < BasicEventTest, const int > (this, &BasicEventTest::onConstSimple);
|
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple -= Delegate < BasicEventTest, const int > (this, &BasicEventTest::onConstSimple);
|
ConstSimple -= Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate < BasicEventTest, Poco::EventArgs* > (this, &BasicEventTest::onComplex);
|
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||||
Complex -= Delegate < BasicEventTest, Poco::EventArgs* > (this, &BasicEventTest::onComplex);
|
Complex -= Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += Delegate < BasicEventTest, Poco::EventArgs > (this, &BasicEventTest::onComplex2);
|
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||||
Complex2 -= Delegate < BasicEventTest, Poco::EventArgs > (this, &BasicEventTest::onComplex2);
|
Complex2 -= Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate < BasicEventTest, const Poco::EventArgs* > (this, &BasicEventTest::onConstComplex);
|
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||||
ConstComplex -= Delegate < BasicEventTest, const Poco::EventArgs* > (this, &BasicEventTest::onConstComplex);
|
ConstComplex -= Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
||||||
ConstComplex.notify ( this, pCArgs );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += Delegate < BasicEventTest, const Poco::EventArgs* const > (this, &BasicEventTest::onConst2Complex);
|
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex -= Delegate < BasicEventTest, const Poco::EventArgs* const > (this, &BasicEventTest::onConst2Complex);
|
Const2Complex -= Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testSingleDelegate()
|
void BasicEventTest::testSingleDelegate()
|
||||||
|
@ -103,219 +103,219 @@ void BasicEventTest::testSingleDelegate()
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
EventArgs args;
|
EventArgs args;
|
||||||
|
|
||||||
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 );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += Delegate < BasicEventTest, const int > (this, &BasicEventTest::onConstSimple);
|
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate < BasicEventTest, Poco::EventArgs* > (this, &BasicEventTest::onComplex);
|
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += Delegate < BasicEventTest, Poco::EventArgs > (this, &BasicEventTest::onComplex2);
|
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 4 );
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
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 );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 5 );
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += Delegate < BasicEventTest, const Poco::EventArgs* const > (this, &BasicEventTest::onConst2Complex);
|
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 6 );
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 7 );
|
assert (_count == 7);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testDuplicateRegister ()
|
void BasicEventTest::testDuplicateRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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 += Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testDuplicateUnregister ()
|
void BasicEventTest::testDuplicateUnregister()
|
||||||
{
|
{
|
||||||
// duplicate unregister shouldn't give an error,
|
// duplicate unregister shouldn't give an error,
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple); // should work
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple); // should work
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testDisabling ()
|
void BasicEventTest::testDisabling()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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.disable ();
|
Simple.disable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable ();
|
Simple.disable();
|
||||||
Simple -= Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple);
|
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testExpire ()
|
void BasicEventTest::testExpire()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire < int > (Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple), 500 );
|
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 700 );
|
Poco::Thread::sleep(700);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testExpireReRegister()
|
void BasicEventTest::testExpireReRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire < int > (Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple), 500 );
|
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 200 );
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += Expire < int > (Delegate < BasicEventTest, int > (this, &BasicEventTest::onSimple), 600 );
|
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 600);
|
||||||
Poco::Thread::sleep( 400 );
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
Poco::Thread::sleep( 300 );
|
Poco::Thread::sleep(300);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testReturnParams ()
|
void BasicEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testOverwriteDelegate ()
|
void BasicEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
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
|
// 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
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2), 23000);
|
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testAsyncNotify ()
|
void BasicEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::BasicEvent < int >* pSimple= new Poco::BasicEvent < int >();
|
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
||||||
(*pSimple) += Delegate < BasicEventTest, int > (this, &BasicEventTest::onAsync);
|
(*pSimple) += Delegate<BasicEventTest, int>(this, &BasicEventTest::onAsync);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
int tmp = 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!
|
delete pSimple; // must work even when the event got deleted!
|
||||||
pSimple = NULL;
|
pSimple = NULL;
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
retArg.wait ();
|
retArg.wait();
|
||||||
poco_assert ( retArg.data() == tmp );
|
assert (retArg.data() == tmp);
|
||||||
poco_assert ( _count == LARGEINC );
|
assert (_count == LARGEINC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onSimple ( const void* pSender, int& i )
|
void BasicEventTest::onSimple(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onSimpleOther ( const void* pSender, int& i )
|
void BasicEventTest::onSimpleOther(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count+=100;
|
_count+=100;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onConstSimple ( const void* pSender, const int& i )
|
void BasicEventTest::onConstSimple(const void* pSender, const int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
void BasicEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
void BasicEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
void BasicEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
void BasicEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_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 ;
|
_count += LARGEINC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BasicEventTest::getCount () const
|
int BasicEventTest::getCount() const
|
||||||
{
|
{
|
||||||
return _count;
|
return _count;
|
||||||
}
|
}
|
||||||
|
@ -326,12 +326,12 @@ void BasicEventTest::setUp()
|
||||||
// must clear events, otherwise repeating test executions will fail
|
// must clear events, otherwise repeating test executions will fail
|
||||||
// because tests are only created once, only setup is called before
|
// because tests are only created once, only setup is called before
|
||||||
// each test run
|
// each test run
|
||||||
Simple.clear ();
|
Simple.clear();
|
||||||
ConstSimple.clear ();
|
ConstSimple.clear();
|
||||||
Complex.clear ();
|
Complex.clear();
|
||||||
Complex2.clear ();
|
Complex2.clear();
|
||||||
ConstComplex.clear ();
|
ConstComplex.clear();
|
||||||
Const2Complex.clear ();
|
Const2Complex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// BasicEventTest.h
|
// 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
|
// Tests for BasicEvent
|
||||||
//
|
//
|
||||||
|
@ -56,14 +56,14 @@ public:
|
||||||
|
|
||||||
void testNoDelegate();
|
void testNoDelegate();
|
||||||
void testSingleDelegate();
|
void testSingleDelegate();
|
||||||
void testDuplicateRegister ();
|
void testDuplicateRegister();
|
||||||
void testDuplicateUnregister ();
|
void testDuplicateUnregister();
|
||||||
void testDisabling ();
|
void testDisabling();
|
||||||
void testExpire();
|
void testExpire();
|
||||||
void testExpireReRegister();
|
void testExpireReRegister();
|
||||||
void testReturnParams ();
|
void testReturnParams();
|
||||||
void testOverwriteDelegate ();
|
void testOverwriteDelegate();
|
||||||
void testAsyncNotify ();
|
void testAsyncNotify();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@ -71,16 +71,16 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void onSimple ( const void* pSender, int& i );
|
void onSimple(const void* pSender, int& i);
|
||||||
void onSimpleOther ( const void* pSender, int& i );
|
void onSimpleOther(const void* pSender, int& i);
|
||||||
void onConstSimple ( const void* pSender, const int& i );
|
void onConstSimple(const void* pSender, const int& i);
|
||||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||||
void onAsync ( const void* pSender, int& i );
|
void onAsync(const void* pSender, int& i);
|
||||||
|
|
||||||
int getCount () const;
|
int getCount() const;
|
||||||
private:
|
private:
|
||||||
int _count;
|
int _count;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ClassLoaderTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -171,7 +171,7 @@ void ClassLoaderTest::testClassLoader2()
|
||||||
}
|
}
|
||||||
|
|
||||||
const AbstractMetaObject<TestPlugin>& meta1 = cl.classFor("PluginC");
|
const AbstractMetaObject<TestPlugin>& meta1 = cl.classFor("PluginC");
|
||||||
assert(meta1.isAutoDelete(&(meta1.instance())));
|
assert (meta1.isAutoDelete(&(meta1.instance())));
|
||||||
|
|
||||||
// the following must not produce memory leaks
|
// the following must not produce memory leaks
|
||||||
const AbstractMetaObject<TestPlugin>& meta2 = cl.classFor("PluginA");
|
const AbstractMetaObject<TestPlugin>& meta2 = cl.classFor("PluginA");
|
||||||
|
@ -180,9 +180,9 @@ void ClassLoaderTest::testClassLoader2()
|
||||||
|
|
||||||
TestPlugin* pPlugin = meta2.create();
|
TestPlugin* pPlugin = meta2.create();
|
||||||
meta2.autoDelete(pPlugin);
|
meta2.autoDelete(pPlugin);
|
||||||
assert(meta2.isAutoDelete(pPlugin));
|
assert (meta2.isAutoDelete(pPlugin));
|
||||||
meta2.destroy(pPlugin);
|
meta2.destroy(pPlugin);
|
||||||
assert(!meta2.isAutoDelete(pPlugin));
|
assert (!meta2.isAutoDelete(pPlugin));
|
||||||
|
|
||||||
cl.unloadLibrary(path);
|
cl.unloadLibrary(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DateTimeTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -599,18 +599,18 @@ void DateTimeTest::testSwap()
|
||||||
void DateTimeTest::testUsage()
|
void DateTimeTest::testUsage()
|
||||||
{
|
{
|
||||||
DateTime dt1(1776, 7, 4);
|
DateTime dt1(1776, 7, 4);
|
||||||
assert(dt1.year() == 1776);
|
assert (dt1.year() == 1776);
|
||||||
assert(dt1.month() == 7);
|
assert (dt1.month() == 7);
|
||||||
assert(dt1.day() == 4);
|
assert (dt1.day() == 4);
|
||||||
|
|
||||||
DateTime dt2(dt1);
|
DateTime dt2(dt1);
|
||||||
dt2 += Timespan(6, 0, 0, 0, 0);
|
dt2 += Timespan(6, 0, 0, 0, 0);
|
||||||
assert(dt2.year() == 1776);
|
assert (dt2.year() == 1776);
|
||||||
assert(dt2.month() == 7);
|
assert (dt2.month() == 7);
|
||||||
assert(dt2.day() == 10);
|
assert (dt2.day() == 10);
|
||||||
|
|
||||||
Timespan span = dt2 - dt1;
|
Timespan span = dt2 - dt1;
|
||||||
assert(span.days() == 6);
|
assert (span.days() == 6);
|
||||||
|
|
||||||
// TODO - When adding months and years we need to be
|
// TODO - When adding months and years we need to be
|
||||||
// able to specify the end-end convention.
|
// 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
|
// TODO - need to be able to assert with the loop counter
|
||||||
// but cppUnit is not able to do this.
|
// but cppUnit is not able to do this.
|
||||||
|
|
||||||
assert(r == x);
|
assert (r == x);
|
||||||
assert(day == X.dayOfYear());
|
assert (day == X.dayOfYear());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DummyDelegate.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -33,20 +33,20 @@
|
||||||
#include "DummyDelegate.h"
|
#include "DummyDelegate.h"
|
||||||
#include "Poco/Exception.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();
|
throw Poco::InvalidArgumentException();
|
||||||
}
|
}
|
||||||
i++;
|
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();
|
throw Poco::InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ExpireCacheTest.cpp
|
// 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.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -47,7 +47,7 @@ using namespace Poco;
|
||||||
#define DURWAIT 300
|
#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()
|
void ExpireCacheTest::testClear()
|
||||||
{
|
{
|
||||||
ExpireCache < int, int > aCache( DURSLEEP );
|
ExpireCache<int, int> aCache(DURSLEEP);
|
||||||
aCache.add(1, 2);
|
aCache.add(1, 2);
|
||||||
aCache.add(3, 4);
|
aCache.add(3, 4);
|
||||||
aCache.add(5, 6);
|
aCache.add(5, 6);
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
assert (*aCache.get(3) == 4);
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
assert (*aCache.get(5) == 6);
|
||||||
aCache.clear();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ void ExpireCacheTest::testExpire0()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExpireCache < int, int > aCache( 24 );
|
ExpireCache<int, int> aCache(24);
|
||||||
failmsg ( "cache expire lower than 25 is illegal, test should fail");
|
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 represents the cache sorted by age, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
ExpireCache < int, int > aCache( DURSLEEP );
|
ExpireCache<int, int> aCache(DURSLEEP);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
SharedPtr < int > tmp = aCache.get( 1 );
|
SharedPtr<int> tmp = aCache.get(1);
|
||||||
poco_assert ( tmp );
|
assert (!tmp.isNull());
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
Thread::sleep( DURWAIT );
|
Thread::sleep(DURWAIT);
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
|
|
||||||
// tmp must still be valid, access it
|
// tmp must still be valid, access it
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
poco_assert ( !tmp );
|
assert (!tmp);
|
||||||
|
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
Thread::sleep( DURHALFSLEEP );
|
Thread::sleep(DURHALFSLEEP);
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
SharedPtr < int > tmp2 = aCache.get( 3 );
|
SharedPtr<int> tmp2 = aCache.get(3);
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
|
|
||||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *tmp == 2 ); // 1-3
|
assert (*tmp == 2); // 1-3
|
||||||
poco_assert ( *tmp2 == 4 ); // 3-1
|
assert (*tmp2 == 4); // 3-1
|
||||||
tmp2 = aCache.get( 3 );
|
tmp2 = aCache.get(3);
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
tmp2 = aCache.get( 3 );
|
tmp2 = aCache.get(3);
|
||||||
poco_assert ( !tmp );
|
assert (!tmp);
|
||||||
poco_assert ( !tmp2 );
|
assert (!tmp2);
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpireCacheTest::testDuplicateAdd()
|
void ExpireCacheTest::testDuplicateAdd()
|
||||||
{
|
{
|
||||||
ExpireCache < int, int > aCache( DURSLEEP );
|
ExpireCache<int, int> aCache(DURSLEEP);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 2);
|
assert (*aCache.get(1) == 2);
|
||||||
aCache.add(1, 3);
|
aCache.add(1, 3);
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 3);
|
assert (*aCache.get(1) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ExpireLRUCacheTest.cpp
|
// 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.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -47,7 +47,7 @@ using namespace Poco;
|
||||||
#define DURWAIT 300
|
#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()
|
void ExpireLRUCacheTest::testClear()
|
||||||
{
|
{
|
||||||
ExpireLRUCache < int, int > aCache( DURSLEEP );
|
ExpireLRUCache<int, int> aCache(DURSLEEP);
|
||||||
aCache.add(1, 2);
|
aCache.add(1, 2);
|
||||||
aCache.add(3, 4);
|
aCache.add(3, 4);
|
||||||
aCache.add(5, 6);
|
aCache.add(5, 6);
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
assert (*aCache.get(3) == 4);
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
assert (*aCache.get(5) == 6);
|
||||||
aCache.clear();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ void ExpireLRUCacheTest::testExpire0()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExpireLRUCache < int, int > aCache( 1024, 24 );
|
ExpireLRUCache<int, int> aCache(1024, 24);
|
||||||
failmsg ( "cache expire lower than 25 is illegal, test should fail");
|
failmsg("cache expire lower than 25 is illegal, test should fail");
|
||||||
}
|
}
|
||||||
catch (Poco::InvalidArgumentException&)
|
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 represents the cache sorted by age, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
ExpireLRUCache < int, int > aCache( 3, DURSLEEP );
|
ExpireLRUCache<int, int> aCache(3, DURSLEEP);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
SharedPtr < int > tmp = aCache.get( 1 );
|
SharedPtr<int> tmp = aCache.get(1);
|
||||||
poco_assert ( tmp );
|
assert (!tmp.isNull());
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
Thread::sleep( DURWAIT );
|
Thread::sleep(DURWAIT);
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
|
|
||||||
// tmp must still be valid, access it
|
// tmp must still be valid, access it
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
poco_assert ( !tmp );
|
assert (!tmp);
|
||||||
|
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
Thread::sleep( DURHALFSLEEP );
|
Thread::sleep(DURHALFSLEEP);
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
SharedPtr < int > tmp2 = aCache.get( 3 );
|
SharedPtr<int> tmp2 = aCache.get(3);
|
||||||
poco_assert ( *tmp == 2 );
|
assert (*tmp == 2);
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
|
|
||||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *tmp == 2 ); // 1-3
|
assert (*tmp == 2); // 1-3
|
||||||
poco_assert ( *tmp2 == 4 ); // 3-1
|
assert (*tmp2 == 4); // 3-1
|
||||||
tmp2 = aCache.get( 3 );
|
tmp2 = aCache.get(3);
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
Thread::sleep( DURHALFSLEEP+25 ); //3|1
|
Thread::sleep(DURHALFSLEEP+25); //3|1
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( *tmp2 == 4 );
|
assert (*tmp2 == 4);
|
||||||
tmp = aCache.get( 1 );
|
tmp = aCache.get(1);
|
||||||
tmp2 = aCache.get( 3 );
|
tmp2 = aCache.get(3);
|
||||||
poco_assert ( !tmp );
|
assert (!tmp);
|
||||||
poco_assert ( !tmp2 );
|
assert (!tmp2);
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ void ExpireLRUCacheTest::testCacheSize0()
|
||||||
// cache size 0 is illegal
|
// cache size 0 is illegal
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExpireLRUCache < int, int > aCache( 0 );
|
ExpireLRUCache<int, int> aCache(0);
|
||||||
failmsg ("cache size of 0 is illegal, test should fail");
|
failmsg ("cache size of 0 is illegal, test should fail");
|
||||||
}
|
}
|
||||||
catch (Poco::InvalidArgumentException&)
|
catch (Poco::InvalidArgumentException&)
|
||||||
|
@ -157,24 +157,24 @@ void ExpireLRUCacheTest::testCacheSize0()
|
||||||
|
|
||||||
void ExpireLRUCacheTest::testCacheSize1()
|
void ExpireLRUCacheTest::testCacheSize1()
|
||||||
{
|
{
|
||||||
ExpireLRUCache < int, int > aCache( 1 );
|
ExpireLRUCache<int, int> aCache(1);
|
||||||
aCache.add(1, 2);
|
aCache.add(1, 2);
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // replaces 1
|
aCache.add(3, 4); // replaces 1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
assert (*aCache.get(3) == 4);
|
||||||
|
|
||||||
aCache.add(5, 6);
|
aCache.add(5, 6);
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
assert (*aCache.get(5) == 6);
|
||||||
|
|
||||||
aCache.remove(5);
|
aCache.remove(5);
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
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 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
ExpireLRUCache < int, int > aCache( 2 );
|
ExpireLRUCache<int, int> aCache(2);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
assert (*aCache.get(1) == 2); // 1-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
assert (*aCache.get(3) == 4); // 3-1
|
||||||
|
|
||||||
aCache.add(5, 6); // 5-3|1
|
aCache.add(5, 6); // 5-3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
assert (*aCache.get(5) == 6); // 5-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
assert (*aCache.get(3) == 4); // 3-5
|
||||||
|
|
||||||
// test remove from the end and the beginning of the list
|
// test remove from the end and the beginning of the list
|
||||||
aCache.remove(5); // 3
|
aCache.remove(5); // 3
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3
|
assert (*aCache.get(3) == 4); // 3
|
||||||
aCache.add(5, 6); // 5-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
|
aCache.remove(3); // 5
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5
|
assert (*aCache.get(5) == 6); // 5
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
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 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
ExpireLRUCache < int, int > aCache( 3 );
|
ExpireLRUCache<int, int> aCache(3);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
assert (*aCache.get(1) == 2); // 1-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
assert (*aCache.get(3) == 4); // 3-1
|
||||||
|
|
||||||
aCache.add(5, 6); // 5-3-1
|
aCache.add(5, 6); // 5-3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3-1
|
assert (*aCache.get(5) == 6); // 5-3-1
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-1
|
assert (*aCache.get(3) == 4); // 3-5-1
|
||||||
|
|
||||||
aCache.add(7, 8); // 7-5-3|1
|
aCache.add(7, 8); // 7-5-3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 7 ) );
|
assert (aCache.has(7));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-7-3
|
assert (*aCache.get(5) == 6); // 5-7-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-7
|
assert (*aCache.get(3) == 4); // 3-5-7
|
||||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-3-5
|
assert (*aCache.get(7) == 8); // 7-3-5
|
||||||
|
|
||||||
// test remove from the end and the beginning of the list
|
// test remove from the end and the beginning of the list
|
||||||
aCache.remove(5); // 7-3
|
aCache.remove(5); // 7-3
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-7
|
assert (*aCache.get(3) == 4); // 3-7
|
||||||
aCache.add(5, 6); // 5-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
|
aCache.remove(7); // 5-3
|
||||||
poco_assert ( !aCache.has( 7 ) );
|
assert (!aCache.has(7));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
assert (*aCache.get(5) == 6); // 5-3
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpireLRUCacheTest::testDuplicateAdd()
|
void ExpireLRUCacheTest::testDuplicateAdd()
|
||||||
{
|
{
|
||||||
ExpireLRUCache < int, int > aCache( 3 );
|
ExpireLRUCache<int, int> aCache(3);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 2);
|
assert (*aCache.get(1) == 2);
|
||||||
aCache.add(1, 3);
|
aCache.add(1, 3);
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 3);
|
assert (*aCache.get(1) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// FIFOEventTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
||||||
#define LARGEINC 100
|
#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;
|
int tmp = 0;
|
||||||
EventArgs args;
|
EventArgs args;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += Delegate < FIFOEventTest, const int > (this, &FIFOEventTest::onConstSimple);
|
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple -= Delegate < FIFOEventTest, const int > (this, &FIFOEventTest::onConstSimple);
|
ConstSimple -= Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate < FIFOEventTest, Poco::EventArgs* > (this, &FIFOEventTest::onComplex);
|
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||||
Complex -= Delegate < FIFOEventTest, Poco::EventArgs* > (this, &FIFOEventTest::onComplex);
|
Complex -= Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += Delegate < FIFOEventTest, Poco::EventArgs > (this, &FIFOEventTest::onComplex2);
|
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2 -= Delegate < FIFOEventTest, Poco::EventArgs > (this, &FIFOEventTest::onComplex2);
|
Complex2 -= Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate < FIFOEventTest, const Poco::EventArgs* > (this, &FIFOEventTest::onConstComplex);
|
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||||
ConstComplex -= Delegate < FIFOEventTest, const Poco::EventArgs* > (this, &FIFOEventTest::onConstComplex);
|
ConstComplex -= Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
||||||
ConstComplex.notify ( this, pCArgs );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += Delegate < FIFOEventTest, const Poco::EventArgs* const > (this, &FIFOEventTest::onConst2Complex);
|
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex -= Delegate < FIFOEventTest, const Poco::EventArgs* const > (this, &FIFOEventTest::onConst2Complex);
|
Const2Complex -= Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testSingleDelegate()
|
void FIFOEventTest::testSingleDelegate()
|
||||||
|
@ -103,194 +103,194 @@ void FIFOEventTest::testSingleDelegate()
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
EventArgs args;
|
EventArgs args;
|
||||||
|
|
||||||
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 );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += Delegate < FIFOEventTest, const int > (this, &FIFOEventTest::onConstSimple);
|
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate < FIFOEventTest, Poco::EventArgs* > (this, &FIFOEventTest::onComplex);
|
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += Delegate < FIFOEventTest, Poco::EventArgs > (this, &FIFOEventTest::onComplex2);
|
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 4 );
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
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 );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 5 );
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += Delegate < FIFOEventTest, const Poco::EventArgs* const > (this, &FIFOEventTest::onConst2Complex);
|
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 6 );
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 7 );
|
assert (_count == 7);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testDuplicateRegister ()
|
void FIFOEventTest::testDuplicateRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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 += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testDuplicateUnregister ()
|
void FIFOEventTest::testDuplicateUnregister()
|
||||||
{
|
{
|
||||||
// duplicate unregister shouldn't give an error,
|
// duplicate unregister shouldn't give an error,
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple); // should work
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple); // should work
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FIFOEventTest::testDisabling ()
|
void FIFOEventTest::testDisabling()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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.disable ();
|
Simple.disable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable ();
|
Simple.disable();
|
||||||
Simple -= Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple);
|
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testFIFOOrder ()
|
void FIFOEventTest::testFIFOOrder()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
DummyDelegate o2;
|
DummyDelegate o2;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
Simple += Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple -= Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
Simple -= Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
failmsg ("Notify should not work");
|
failmsg ("Notify should not work");
|
||||||
}
|
}
|
||||||
catch ( Poco::InvalidArgumentException& )
|
catch (Poco::InvalidArgumentException&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testFIFOOrderExpire ()
|
void FIFOEventTest::testFIFOOrderExpire()
|
||||||
{
|
{
|
||||||
// expire must not break order!
|
// expire must not break order!
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
DummyDelegate o2;
|
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>(&o1, &DummyDelegate::onSimple), 5000);
|
||||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2), 5000 );
|
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// both ways of unregistering should work
|
// both ways of unregistering should work
|
||||||
Simple -= Expire < int > ( Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple), 6000 );
|
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
||||||
Simple -= Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now start mixing of expire and non expire
|
// now start mixing of expire and non expire
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2), 5000 );
|
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2);
|
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 ;-) )
|
// 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 -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2), 5000 );
|
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
failmsg ("Notify should not work");
|
failmsg ("Notify should not work");
|
||||||
}
|
}
|
||||||
catch ( Poco::InvalidArgumentException& )
|
catch (Poco::InvalidArgumentException&)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testExpire ()
|
void FIFOEventTest::testExpire()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire < int > (Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple), 500 );
|
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 700 );
|
Poco::Thread::sleep(700);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,108 +298,108 @@ void FIFOEventTest::testExpireReRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire < int > (Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple), 500 );
|
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 200 );
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += Expire < int > (Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onSimple), 600 );
|
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 600);
|
||||||
Poco::Thread::sleep( 400 );
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
Poco::Thread::sleep( 300 );
|
Poco::Thread::sleep(300);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FIFOEventTest::testReturnParams ()
|
void FIFOEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple);
|
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testOverwriteDelegate ()
|
void FIFOEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
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
|
// 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
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
Simple += Expire < int > ( Delegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple2), 23000);
|
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::testAsyncNotify ()
|
void FIFOEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::FIFOEvent < int >* pSimple= new Poco::FIFOEvent < int >();
|
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
||||||
(*pSimple) += Delegate < FIFOEventTest, int > (this, &FIFOEventTest::onAsync);
|
(*pSimple) += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onAsync);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
int tmp = 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!
|
delete pSimple; // must work even when the event got deleted!
|
||||||
pSimple = NULL;
|
pSimple = NULL;
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
retArg.wait ();
|
retArg.wait();
|
||||||
poco_assert ( retArg.data() == tmp );
|
assert (retArg.data() == tmp);
|
||||||
poco_assert ( _count == LARGEINC );
|
assert (_count == LARGEINC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onSimple ( const void* pSender, int& i )
|
void FIFOEventTest::onSimple(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onSimpleOther ( const void* pSender, int& i )
|
void FIFOEventTest::onSimpleOther(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count+=100;
|
_count+=100;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onConstSimple ( const void* pSender, const int& i )
|
void FIFOEventTest::onConstSimple(const void* pSender, const int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
void FIFOEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
void FIFOEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
void FIFOEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFOEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
void FIFOEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_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 ;
|
_count += LARGEINC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIFOEventTest::getCount () const
|
int FIFOEventTest::getCount() const
|
||||||
{
|
{
|
||||||
return _count;
|
return _count;
|
||||||
}
|
}
|
||||||
|
@ -410,12 +410,12 @@ void FIFOEventTest::setUp()
|
||||||
// must clear events, otherwise repeating test executions will fail
|
// must clear events, otherwise repeating test executions will fail
|
||||||
// because tests are only created once, only setup is called before
|
// because tests are only created once, only setup is called before
|
||||||
// each test run
|
// each test run
|
||||||
Simple.clear ();
|
Simple.clear();
|
||||||
ConstSimple.clear ();
|
ConstSimple.clear();
|
||||||
Complex.clear ();
|
Complex.clear();
|
||||||
Complex2.clear ();
|
Complex2.clear();
|
||||||
ConstComplex.clear ();
|
ConstComplex.clear();
|
||||||
Const2Complex.clear ();
|
Const2Complex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// FIFOEventTest.h
|
// 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.
|
// Definition of the FIFOEventTest class.
|
||||||
//
|
//
|
||||||
|
@ -56,16 +56,16 @@ public:
|
||||||
|
|
||||||
void testNoDelegate();
|
void testNoDelegate();
|
||||||
void testSingleDelegate();
|
void testSingleDelegate();
|
||||||
void testDuplicateRegister ();
|
void testDuplicateRegister();
|
||||||
void testDuplicateUnregister ();
|
void testDuplicateUnregister();
|
||||||
void testDisabling ();
|
void testDisabling();
|
||||||
void testFIFOOrder ();
|
void testFIFOOrder();
|
||||||
void testFIFOOrderExpire ();
|
void testFIFOOrderExpire();
|
||||||
void testExpire ();
|
void testExpire();
|
||||||
void testExpireReRegister();
|
void testExpireReRegister();
|
||||||
void testReturnParams ();
|
void testReturnParams();
|
||||||
void testOverwriteDelegate ();
|
void testOverwriteDelegate();
|
||||||
void testAsyncNotify ();
|
void testAsyncNotify();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@ -73,16 +73,16 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void onSimple ( const void* pSender, int& i );
|
void onSimple(const void* pSender, int& i);
|
||||||
void onSimpleOther ( const void* pSender, int& i );
|
void onSimpleOther(const void* pSender, int& i);
|
||||||
void onConstSimple ( const void* pSender, const int& i );
|
void onConstSimple(const void* pSender, const int& i);
|
||||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||||
void onAsync ( const void* pSender, int& i );
|
void onAsync(const void* pSender, int& i);
|
||||||
|
|
||||||
int getCount () const;
|
int getCount() const;
|
||||||
private:
|
private:
|
||||||
int _count;
|
int _count;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// HashTest.cpp
|
// 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.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -54,31 +54,31 @@ void HashTest::testInsert()
|
||||||
{
|
{
|
||||||
std::string s1("str1");
|
std::string s1("str1");
|
||||||
std::string s2("str2");
|
std::string s2("str2");
|
||||||
HashTable < std::string, int > hashTable;
|
HashTable<std::string, int> hashTable;
|
||||||
poco_assert (!hashTable.exists(s1));
|
assert (!hashTable.exists(s1));
|
||||||
hashTable.insert(s1, 13);
|
hashTable.insert(s1, 13);
|
||||||
poco_assert (hashTable.exists(s1));
|
assert (hashTable.exists(s1));
|
||||||
poco_assert (hashTable.get(s1) == 13);
|
assert (hashTable.get(s1) == 13);
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
poco_assert (hashTable.get(s1, retVal));
|
assert (hashTable.get(s1, retVal));
|
||||||
poco_assert (retVal == 13);
|
assert (retVal == 13);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hashTable.insert(s1, 22);
|
hashTable.insert(s1, 22);
|
||||||
failmsg ("duplicate insert must fail");
|
failmsg ("duplicate insert must fail");
|
||||||
}
|
}
|
||||||
catch(Exception&){}
|
catch (Exception&){}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hashTable.get(s2);
|
hashTable.get(s2);
|
||||||
failmsg ("getting a non inserted item must fail");
|
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);
|
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
|
// add code for second test here
|
||||||
std::string s1("str1");
|
std::string s1("str1");
|
||||||
std::string s2("str2");
|
std::string s2("str2");
|
||||||
HashTable < std::string, int > hashTable;
|
HashTable<std::string, int> hashTable;
|
||||||
hashTable.insert(s1, 13);
|
hashTable.insert(s1, 13);
|
||||||
hashTable.update(s1, 14);
|
hashTable.update(s1, 14);
|
||||||
poco_assert (hashTable.exists(s1));
|
assert (hashTable.exists(s1));
|
||||||
poco_assert (hashTable.get(s1) == 14);
|
assert (hashTable.get(s1) == 14);
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
poco_assert (hashTable.get(s1, retVal));
|
assert (hashTable.get(s1, retVal));
|
||||||
poco_assert (retVal == 14);
|
assert (retVal == 14);
|
||||||
|
|
||||||
// updating a non existing item must work too
|
// updating a non existing item must work too
|
||||||
hashTable.update(s2, 15);
|
hashTable.update(s2, 15);
|
||||||
poco_assert (hashTable.get(s2) == 15);
|
assert (hashTable.get(s2) == 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HashTest::testOverflow()
|
void HashTest::testOverflow()
|
||||||
{
|
{
|
||||||
HashTable < std::string, int > hashTable(13);
|
HashTable<std::string, int> hashTable(13);
|
||||||
for (int i = 0; i < 1024; ++i)
|
for (int i = 0; i < 1024; ++i)
|
||||||
{
|
{
|
||||||
hashTable.insert(Poco::NumberFormatter::format(i), i*i);
|
hashTable.insert(Poco::NumberFormatter::format(i), i*i);
|
||||||
|
@ -114,38 +114,38 @@ void HashTest::testOverflow()
|
||||||
for (int i = 0; i < 1024; ++i)
|
for (int i = 0; i < 1024; ++i)
|
||||||
{
|
{
|
||||||
std::string tmp = Poco::NumberFormatter::format(i);
|
std::string tmp = Poco::NumberFormatter::format(i);
|
||||||
poco_assert (hashTable.exists(tmp));
|
assert (hashTable.exists(tmp));
|
||||||
poco_assert (hashTable.get(tmp) == i*i);
|
assert (hashTable.get(tmp) == i*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HashTest::testSize()
|
void HashTest::testSize()
|
||||||
{
|
{
|
||||||
HashTable < std::string, int > hashTable(13);
|
HashTable<std::string, int> hashTable(13);
|
||||||
poco_assert (hashTable.size() == 0);
|
assert (hashTable.size() == 0);
|
||||||
Poco::UInt32 h1 = hashTable.insert("1", 1);
|
Poco::UInt32 h1 = hashTable.insert("1", 1);
|
||||||
poco_assert (hashTable.size() == 1);
|
assert (hashTable.size() == 1);
|
||||||
Poco::UInt32 h2 = hashTable.update("2", 2);
|
Poco::UInt32 h2 = hashTable.update("2", 2);
|
||||||
poco_assert (hashTable.size() == 2);
|
assert (hashTable.size() == 2);
|
||||||
hashTable.remove("1");
|
hashTable.remove("1");
|
||||||
poco_assert (hashTable.size() == 1);
|
assert (hashTable.size() == 1);
|
||||||
hashTable.remove("3");
|
hashTable.remove("3");
|
||||||
poco_assert (hashTable.size() == 1);
|
assert (hashTable.size() == 1);
|
||||||
hashTable.removeRaw("2", h2);
|
hashTable.removeRaw("2", h2);
|
||||||
poco_assert (hashTable.size() == 0);
|
assert (hashTable.size() == 0);
|
||||||
hashTable.insert("1", 1);
|
hashTable.insert("1", 1);
|
||||||
hashTable.insert("2", 2);
|
hashTable.insert("2", 2);
|
||||||
poco_assert (hashTable.size() == 2);
|
assert (hashTable.size() == 2);
|
||||||
hashTable.clear();
|
hashTable.clear();
|
||||||
poco_assert (hashTable.size() == 0);
|
assert (hashTable.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HashTest::testResize()
|
void HashTest::testResize()
|
||||||
{
|
{
|
||||||
HashTable < std::string, int > hashTable(13);
|
HashTable<std::string, int> hashTable(13);
|
||||||
poco_assert (hashTable.size() == 0);
|
assert (hashTable.size() == 0);
|
||||||
hashTable.resize(19);
|
hashTable.resize(19);
|
||||||
for (int i = 0; i < 1024; ++i)
|
for (int i = 0; i < 1024; ++i)
|
||||||
{
|
{
|
||||||
|
@ -156,8 +156,8 @@ void HashTest::testResize()
|
||||||
for (int i = 0; i < 1024; ++i)
|
for (int i = 0; i < 1024; ++i)
|
||||||
{
|
{
|
||||||
std::string tmp = Poco::NumberFormatter::format(i);
|
std::string tmp = Poco::NumberFormatter::format(i);
|
||||||
poco_assert (hashTable.exists(tmp));
|
assert (hashTable.exists(tmp));
|
||||||
poco_assert (hashTable.get(tmp) == i*i);
|
assert (hashTable.get(tmp) == i*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,19 +165,19 @@ void HashTest::testResize()
|
||||||
void HashTest::testStatistic()
|
void HashTest::testStatistic()
|
||||||
{
|
{
|
||||||
double relax = 0.001;
|
double relax = 0.001;
|
||||||
HashTable < std::string, int > hashTable(13);
|
HashTable<std::string, int> hashTable(13);
|
||||||
poco_assert (hashTable.size() == 0);
|
assert (hashTable.size() == 0);
|
||||||
HashStatistic stat1(hashTable.currentState());
|
HashStatistic stat1(hashTable.currentState());
|
||||||
poco_assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||||
poco_assert (stat1.maxPositionsOfTable() == 13);
|
assert (stat1.maxPositionsOfTable() == 13);
|
||||||
poco_assert (stat1.maxEntriesPerHash() == 0);
|
assert (stat1.maxEntriesPerHash() == 0);
|
||||||
|
|
||||||
hashTable.resize(19);
|
hashTable.resize(19);
|
||||||
stat1 = hashTable.currentState(true);
|
stat1 = hashTable.currentState(true);
|
||||||
poco_assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
|
||||||
poco_assert (stat1.maxPositionsOfTable() == 19);
|
assert (stat1.maxPositionsOfTable() == 19);
|
||||||
poco_assert (stat1.maxEntriesPerHash() == 0);
|
assert (stat1.maxEntriesPerHash() == 0);
|
||||||
poco_assert (stat1.detailedEntriesPerHash().size() == 19);
|
assert (stat1.detailedEntriesPerHash().size() == 19);
|
||||||
|
|
||||||
for (int i = 0; i < 1024; ++i)
|
for (int i = 0; i < 1024; ++i)
|
||||||
{
|
{
|
||||||
|
@ -185,17 +185,17 @@ void HashTest::testStatistic()
|
||||||
}
|
}
|
||||||
stat1 = hashTable.currentState(true);
|
stat1 = hashTable.currentState(true);
|
||||||
double expAvg = 1024.0/ 19;
|
double expAvg = 1024.0/ 19;
|
||||||
poco_assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||||
poco_assert (stat1.maxPositionsOfTable() == 19);
|
assert (stat1.maxPositionsOfTable() == 19);
|
||||||
poco_assert (stat1.maxEntriesPerHash() > expAvg);
|
assert (stat1.maxEntriesPerHash() > expAvg);
|
||||||
hashTable.resize(1009);
|
hashTable.resize(1009);
|
||||||
stat1 = hashTable.currentState(true);
|
stat1 = hashTable.currentState(true);
|
||||||
|
|
||||||
expAvg = 1024.0/ 1009;
|
expAvg = 1024.0/ 1009;
|
||||||
|
|
||||||
poco_assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
|
||||||
poco_assert (stat1.maxPositionsOfTable() == 1009);
|
assert (stat1.maxPositionsOfTable() == 1009);
|
||||||
poco_assert (stat1.maxEntriesPerHash() > expAvg);
|
assert (stat1.maxEntriesPerHash() > expAvg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// LRUCacheTest.cpp
|
// 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.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
using namespace Poco;
|
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()
|
void LRUCacheTest::testClear()
|
||||||
{
|
{
|
||||||
LRUCache < int, int > aCache( 3 );
|
LRUCache<int, int> aCache(3);
|
||||||
aCache.add(1, 2);
|
aCache.add(1, 2);
|
||||||
aCache.add(3, 4);
|
aCache.add(3, 4);
|
||||||
aCache.add(5, 6);
|
aCache.add(5, 6);
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
assert (*aCache.get(3) == 4);
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
assert (*aCache.get(5) == 6);
|
||||||
aCache.clear();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void LRUCacheTest::testCacheSize0()
|
||||||
// cache size 0 is illegal
|
// cache size 0 is illegal
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LRUCache < int, int > aCache( 0 );
|
LRUCache<int, int> aCache(0);
|
||||||
failmsg ("cache size of 0 is illegal, test should fail");
|
failmsg ("cache size of 0 is illegal, test should fail");
|
||||||
}
|
}
|
||||||
catch (Poco::InvalidArgumentException&)
|
catch (Poco::InvalidArgumentException&)
|
||||||
|
@ -86,24 +86,24 @@ void LRUCacheTest::testCacheSize0()
|
||||||
|
|
||||||
void LRUCacheTest::testCacheSize1()
|
void LRUCacheTest::testCacheSize1()
|
||||||
{
|
{
|
||||||
LRUCache < int, int > aCache( 1 );
|
LRUCache<int, int> aCache(1);
|
||||||
aCache.add(1, 2);
|
aCache.add(1, 2);
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // replaces 1
|
aCache.add(3, 4); // replaces 1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 );
|
assert (*aCache.get(3) == 4);
|
||||||
|
|
||||||
aCache.add(5, 6);
|
aCache.add(5, 6);
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 );
|
assert (*aCache.get(5) == 6);
|
||||||
|
|
||||||
aCache.remove(5);
|
aCache.remove(5);
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
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 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
LRUCache < int, int > aCache( 2 );
|
LRUCache<int, int> aCache(2);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
assert (*aCache.get(1) == 2); // 1-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
assert (*aCache.get(3) == 4); // 3-1
|
||||||
|
|
||||||
aCache.add(5, 6); // 5-3|1
|
aCache.add(5, 6); // 5-3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
assert (*aCache.get(5) == 6); // 5-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5
|
assert (*aCache.get(3) == 4); // 3-5
|
||||||
|
|
||||||
// test remove from the end and the beginning of the list
|
// test remove from the end and the beginning of the list
|
||||||
aCache.remove(5); // 3
|
aCache.remove(5); // 3
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3
|
assert (*aCache.get(3) == 4); // 3
|
||||||
aCache.add(5, 6); // 5-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
|
aCache.remove(3); // 5
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5
|
assert (*aCache.get(5) == 6); // 5
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
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 represents the cache sorted by pos, elements get replaced at the end of the list
|
||||||
// 3-1|5 -> 5 gets removed
|
// 3-1|5 -> 5 gets removed
|
||||||
LRUCache < int, int > aCache( 3 );
|
LRUCache<int, int> aCache(3);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 );
|
assert (*aCache.get(1) == 2);
|
||||||
|
|
||||||
aCache.add(3, 4); // 3-1
|
aCache.add(3, 4); // 3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 1 ) == 2 ); // 1-3
|
assert (*aCache.get(1) == 2); // 1-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-1
|
assert (*aCache.get(3) == 4); // 3-1
|
||||||
|
|
||||||
aCache.add(5, 6); // 5-3-1
|
aCache.add(5, 6); // 5-3-1
|
||||||
poco_assert ( aCache.has( 1 ) );
|
assert (aCache.has(1));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3-1
|
assert (*aCache.get(5) == 6); // 5-3-1
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-1
|
assert (*aCache.get(3) == 4); // 3-5-1
|
||||||
|
|
||||||
aCache.add(7, 8); // 7-5-3|1
|
aCache.add(7, 8); // 7-5-3|1
|
||||||
poco_assert ( !aCache.has( 1 ) );
|
assert (!aCache.has(1));
|
||||||
poco_assert ( aCache.has( 7 ) );
|
assert (aCache.has(7));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( aCache.has( 5 ) );
|
assert (aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-7-3
|
assert (*aCache.get(5) == 6); // 5-7-3
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-5-7
|
assert (*aCache.get(3) == 4); // 3-5-7
|
||||||
poco_assert ( *aCache.get( 7 ) == 8 ); // 7-3-5
|
assert (*aCache.get(7) == 8); // 7-3-5
|
||||||
|
|
||||||
// test remove from the end and the beginning of the list
|
// test remove from the end and the beginning of the list
|
||||||
aCache.remove(5); // 7-3
|
aCache.remove(5); // 7-3
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( *aCache.get( 3 ) == 4 ); // 3-7
|
assert (*aCache.get(3) == 4); // 3-7
|
||||||
aCache.add(5, 6); // 5-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
|
aCache.remove(7); // 5-3
|
||||||
poco_assert ( !aCache.has( 7 ) );
|
assert (!aCache.has(7));
|
||||||
poco_assert ( aCache.has( 3 ) );
|
assert (aCache.has(3));
|
||||||
poco_assert ( *aCache.get( 5 ) == 6 ); // 5-3
|
assert (*aCache.get(5) == 6); // 5-3
|
||||||
|
|
||||||
// removing illegal entries should work too
|
// removing illegal entries should work too
|
||||||
aCache.remove(666);
|
aCache.remove(666);
|
||||||
|
|
||||||
aCache.clear ();
|
aCache.clear();
|
||||||
poco_assert ( !aCache.has( 5 ) );
|
assert (!aCache.has(5));
|
||||||
poco_assert ( !aCache.has( 3 ) );
|
assert (!aCache.has(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LRUCacheTest::testDuplicateAdd()
|
void LRUCacheTest::testDuplicateAdd()
|
||||||
{
|
{
|
||||||
LRUCache < int, int > aCache( 3 );
|
LRUCache<int, int> aCache(3);
|
||||||
aCache.add(1, 2); // 1
|
aCache.add(1, 2); // 1
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 2);
|
assert (*aCache.get(1) == 2);
|
||||||
aCache.add(1, 3);
|
aCache.add(1, 3);
|
||||||
poco_assert (aCache.has(1));
|
assert (aCache.has(1));
|
||||||
poco_assert (*aCache.get(1) == 3);
|
assert (*aCache.get(1) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// LoggerTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -197,7 +197,7 @@ void LoggerTest::testDump()
|
||||||
|
|
||||||
char buffer1[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
|
char buffer1[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
|
||||||
root.dump("test", buffer1, sizeof(buffer1));
|
root.dump("test", buffer1, sizeof(buffer1));
|
||||||
assert(pChannel->list().empty());
|
assert (pChannel->list().empty());
|
||||||
|
|
||||||
root.setLevel(Message::PRIO_DEBUG);
|
root.setLevel(Message::PRIO_DEBUG);
|
||||||
root.dump("test", buffer1, sizeof(buffer1));
|
root.dump("test", buffer1, sizeof(buffer1));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// PriorityEventTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -46,7 +46,7 @@ using namespace Poco;
|
||||||
#define LARGEINC 100
|
#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;
|
int tmp = 0;
|
||||||
EventArgs args;
|
EventArgs args;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += PriorityDelegate < PriorityEventTest, const int > (this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple -= PriorityDelegate < PriorityEventTest, const int > (this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += PriorityDelegate < PriorityEventTest, Poco::EventArgs* > (this, &PriorityEventTest::onComplex, 0);
|
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex -= PriorityDelegate < PriorityEventTest, Poco::EventArgs* > (this, &PriorityEventTest::onComplex, 0);
|
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += PriorityDelegate < PriorityEventTest, Poco::EventArgs > (this, &PriorityEventTest::onComplex2, 0);
|
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2 -= PriorityDelegate < PriorityEventTest, Poco::EventArgs > (this, &PriorityEventTest::onComplex2, 0);
|
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
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 -= PriorityDelegate < PriorityEventTest, const Poco::EventArgs* > (this, &PriorityEventTest::onConstComplex, 0);
|
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
||||||
ConstComplex.notify ( this, pCArgs );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += PriorityDelegate < PriorityEventTest, const Poco::EventArgs* const > (this, &PriorityEventTest::onConst2Complex, 0);
|
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
||||||
Const2Complex -= 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 );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testSingleDelegate()
|
void PriorityEventTest::testSingleDelegate()
|
||||||
|
@ -103,217 +103,217 @@ void PriorityEventTest::testSingleDelegate()
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
EventArgs args;
|
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
|
// unregistering with a different priority --> different observer, is ignored
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 3);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 3);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += PriorityDelegate < PriorityEventTest, const int > (this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple -= PriorityDelegate < PriorityEventTest, const int > (this, &PriorityEventTest::onConstSimple, 3);
|
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 3);
|
||||||
ConstSimple.notify ( this, tmp );
|
ConstSimple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += PriorityDelegate < PriorityEventTest, Poco::EventArgs* > (this, &PriorityEventTest::onComplex, 0);
|
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex -= PriorityDelegate < PriorityEventTest, Poco::EventArgs* > (this, &PriorityEventTest::onComplex, 3);
|
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 3);
|
||||||
Complex.notify ( this, pArgs );
|
Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += PriorityDelegate < PriorityEventTest, Poco::EventArgs > (this, &PriorityEventTest::onComplex2, 0);
|
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2 -= PriorityDelegate < PriorityEventTest, Poco::EventArgs > (this, &PriorityEventTest::onComplex2, 3);
|
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 3);
|
||||||
Complex2.notify ( this, args );
|
Complex2.notify(this, args);
|
||||||
poco_assert ( _count == 4 );
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
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 -= PriorityDelegate < PriorityEventTest, const Poco::EventArgs* > (this, &PriorityEventTest::onConstComplex, 3);
|
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 3);
|
||||||
ConstComplex.notify ( this, pCArgs );
|
ConstComplex.notify(this, pCArgs);
|
||||||
poco_assert ( _count == 5 );
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += PriorityDelegate < PriorityEventTest, const Poco::EventArgs* const > (this, &PriorityEventTest::onConst2Complex, 0);
|
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
||||||
Const2Complex -= PriorityDelegate < PriorityEventTest, const Poco::EventArgs* const > (this, &PriorityEventTest::onConst2Complex, 3);
|
Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 3);
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 6 );
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
Const2Complex.notify ( this, pArgs );
|
Const2Complex.notify(this, pArgs);
|
||||||
poco_assert ( _count == 7 );
|
assert (_count == 7);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testDuplicateRegister ()
|
void PriorityEventTest::testDuplicateRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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 += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimpleOther, 1);
|
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 + LARGEINC );
|
assert (_count == 2 + LARGEINC);
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimpleOther, 1);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 + LARGEINC );
|
assert (_count == 3 + LARGEINC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testDuplicateUnregister ()
|
void PriorityEventTest::testDuplicateUnregister()
|
||||||
{
|
{
|
||||||
// duplicate unregister shouldn't give an error,
|
// duplicate unregister shouldn't give an error,
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0); // should work
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0); // should work
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityEventTest::testDisabling ()
|
void PriorityEventTest::testDisabling()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
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.disable ();
|
Simple.disable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable ();
|
Simple.disable();
|
||||||
Simple -= PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 0);
|
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.enable ();
|
Simple.enable();
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testPriorityOrder ()
|
void PriorityEventTest::testPriorityOrder()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
DummyDelegate o2;
|
DummyDelegate o2;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
failmsg ("Notify should not work");
|
failmsg ("Notify should not work");
|
||||||
}
|
}
|
||||||
catch ( Poco::InvalidArgumentException& )
|
catch (Poco::InvalidArgumentException&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testPriorityOrderExpire ()
|
void PriorityEventTest::testPriorityOrderExpire()
|
||||||
{
|
{
|
||||||
// expire must not break order!
|
// expire must not break order!
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
DummyDelegate o2;
|
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>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
||||||
Simple += PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0), 500000 );
|
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 500000);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// both ways of unregistering should work
|
// both ways of unregistering should work
|
||||||
Simple -= PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0), 600000 );
|
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now start mixing of expire and non expire
|
// now start mixing of expire and non expire
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple += PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1), 500000 );
|
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 1);
|
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 ;-) )
|
// 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 -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0), 500000 );
|
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
failmsg ("Notify should not work");
|
failmsg ("Notify should not work");
|
||||||
}
|
}
|
||||||
catch ( Poco::InvalidArgumentException& )
|
catch (Poco::InvalidArgumentException&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Simple -= PriorityExpire < int > ( PriorityDelegate < DummyDelegate, int > (&o2, &DummyDelegate::onSimple2, 0), 500000 );
|
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
||||||
Simple -= PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 1);
|
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testExpire ()
|
void PriorityEventTest::testExpire()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
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 );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 700 );
|
Poco::Thread::sleep(700);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,110 +321,110 @@ void PriorityEventTest::testExpireReRegister()
|
||||||
{
|
{
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
|
|
||||||
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 );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 1 );
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep ( 200 );
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 2 );
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += PriorityExpire < int > (PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onSimple, 1), 600 );
|
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 600);
|
||||||
Poco::Thread::sleep( 400 );
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
Poco::Thread::sleep( 300 );
|
Poco::Thread::sleep(300);
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( _count == 3 );
|
assert (_count == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityEventTest::testReturnParams ()
|
void PriorityEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += PriorityDelegate < DummyDelegate, int > (&o1, &DummyDelegate::onSimple, 0);
|
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testOverwriteDelegate ()
|
void PriorityEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
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
|
// 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
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify ( this, tmp );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 1 );
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
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 );
|
Simple.notify(this, tmp);
|
||||||
poco_assert ( tmp == 2 );
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testAsyncNotify ()
|
void PriorityEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::PriorityEvent < int >* pSimple= new Poco::PriorityEvent < int >();
|
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
||||||
(*pSimple) += PriorityDelegate < PriorityEventTest, int > (this, &PriorityEventTest::onAsync, 0);
|
(*pSimple) += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onAsync, 0);
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
int tmp = 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!
|
delete pSimple; // must work even when the event got deleted!
|
||||||
pSimple = NULL;
|
pSimple = NULL;
|
||||||
poco_assert ( _count == 0 );
|
assert (_count == 0);
|
||||||
retArg.wait ();
|
retArg.wait();
|
||||||
poco_assert ( retArg.data() == tmp );
|
assert (retArg.data() == tmp);
|
||||||
poco_assert ( _count == LARGEINC );
|
assert (_count == LARGEINC);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onSimple ( const void* pSender, int& i )
|
void PriorityEventTest::onSimple(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onSimpleOther ( const void* pSender, int& i )
|
void PriorityEventTest::onSimpleOther(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count += LARGEINC ;
|
_count += LARGEINC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onConstSimple ( const void* pSender, const int& i )
|
void PriorityEventTest::onConstSimple(const void* pSender, const int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onComplex ( const void* pSender, Poco::EventArgs* & i )
|
void PriorityEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onComplex2 ( const void* pSender, Poco::EventArgs & i )
|
void PriorityEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onConstComplex ( const void* pSender, const Poco::EventArgs*& i )
|
void PriorityEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i )
|
void PriorityEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||||
{
|
{
|
||||||
_count++;
|
_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 ;
|
_count += LARGEINC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PriorityEventTest::getCount () const
|
int PriorityEventTest::getCount() const
|
||||||
{
|
{
|
||||||
return _count;
|
return _count;
|
||||||
}
|
}
|
||||||
|
@ -435,12 +435,12 @@ void PriorityEventTest::setUp()
|
||||||
// must clear events, otherwise repeating test executions will fail
|
// must clear events, otherwise repeating test executions will fail
|
||||||
// because tests are only created once, only setup is called before
|
// because tests are only created once, only setup is called before
|
||||||
// each test run
|
// each test run
|
||||||
Simple.clear ();
|
Simple.clear();
|
||||||
ConstSimple.clear ();
|
ConstSimple.clear();
|
||||||
Complex.clear ();
|
Complex.clear();
|
||||||
Complex2.clear ();
|
Complex2.clear();
|
||||||
ConstComplex.clear ();
|
ConstComplex.clear();
|
||||||
Const2Complex.clear ();
|
Const2Complex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// PriorityEventTest.h
|
// 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.
|
// Definition of the PriorityEventTest class.
|
||||||
//
|
//
|
||||||
|
@ -56,16 +56,16 @@ public:
|
||||||
|
|
||||||
void testNoDelegate();
|
void testNoDelegate();
|
||||||
void testSingleDelegate();
|
void testSingleDelegate();
|
||||||
void testDuplicateRegister ();
|
void testDuplicateRegister();
|
||||||
void testDuplicateUnregister ();
|
void testDuplicateUnregister();
|
||||||
void testDisabling ();
|
void testDisabling();
|
||||||
void testPriorityOrder ();
|
void testPriorityOrder();
|
||||||
void testPriorityOrderExpire ();
|
void testPriorityOrderExpire();
|
||||||
void testExpire ();
|
void testExpire();
|
||||||
void testExpireReRegister();
|
void testExpireReRegister();
|
||||||
void testReturnParams ();
|
void testReturnParams();
|
||||||
void testOverwriteDelegate ();
|
void testOverwriteDelegate();
|
||||||
void testAsyncNotify ();
|
void testAsyncNotify();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@ -73,16 +73,16 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void onSimple ( const void* pSender, int& i );
|
void onSimple(const void* pSender, int& i);
|
||||||
void onSimpleOther ( const void* pSender, int& i );
|
void onSimpleOther(const void* pSender, int& i);
|
||||||
void onConstSimple ( const void* pSender, const int& i );
|
void onConstSimple(const void* pSender, const int& i);
|
||||||
void onComplex ( const void* pSender, Poco::EventArgs* & i );
|
void onComplex(const void* pSender, Poco::EventArgs* & i);
|
||||||
void onComplex2 ( const void* pSender, Poco::EventArgs & i );
|
void onComplex2(const void* pSender, Poco::EventArgs & i);
|
||||||
void onConstComplex ( const void* pSender, const Poco::EventArgs*& i );
|
void onConstComplex(const void* pSender, const Poco::EventArgs*& i);
|
||||||
void onConst2Complex ( const void* pSender, const Poco::EventArgs * const & i );
|
void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i);
|
||||||
void onAsync ( const void* pSender, int& i );
|
void onAsync(const void* pSender, int& i);
|
||||||
|
|
||||||
int getCount () const;
|
int getCount() const;
|
||||||
private:
|
private:
|
||||||
int _count;
|
int _count;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// SharedPtrTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -112,7 +112,7 @@ void SharedPtrTest::testSharedPtr()
|
||||||
pTO1 = pTO2;
|
pTO1 = pTO2;
|
||||||
pTO2 = pTmp;
|
pTO2 = pTmp;
|
||||||
}
|
}
|
||||||
assert(pTO1 < pTO2);
|
assert (pTO1 < pTO2);
|
||||||
ptr1 = pTO1;
|
ptr1 = pTO1;
|
||||||
SharedPtr<TestObject> ptr2 = pTO2;
|
SharedPtr<TestObject> ptr2 = pTO2;
|
||||||
SharedPtr<TestObject> ptr3 = ptr1;
|
SharedPtr<TestObject> ptr3 = ptr1;
|
||||||
|
@ -181,12 +181,12 @@ void SharedPtrTest::testImplicitCast()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// null assign test
|
// null assign test
|
||||||
SharedPtr < DerivedObject > ptr2;
|
SharedPtr<DerivedObject> ptr2;
|
||||||
assertNull(ptr2.get());
|
assertNull(ptr2.get());
|
||||||
SharedPtr<TestObject> ptr1 = ptr2;
|
SharedPtr<TestObject> ptr1 = ptr2;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SharedPtr < DerivedObject > ptr2(new DerivedObject("test", 666));
|
SharedPtr<DerivedObject> ptr2(new DerivedObject("test", 666));
|
||||||
assert (TestObject::count() == 1);
|
assert (TestObject::count() == 1);
|
||||||
SharedPtr<TestObject> ptr1 = ptr2;
|
SharedPtr<TestObject> ptr1 = ptr2;
|
||||||
assert (TestObject::count() == 1);
|
assert (TestObject::count() == 1);
|
||||||
|
@ -201,7 +201,7 @@ void SharedPtrTest::testImplicitCast()
|
||||||
void SharedPtrTest::testExplicitCast()
|
void SharedPtrTest::testExplicitCast()
|
||||||
{
|
{
|
||||||
SharedPtr<TestObject> ptr1 = new DerivedObject("test", 666);
|
SharedPtr<TestObject> ptr1 = new DerivedObject("test", 666);
|
||||||
SharedPtr < DerivedObject > ptr2 = ptr1.cast<DerivedObject>();
|
SharedPtr<DerivedObject> ptr2 = ptr1.cast<DerivedObject>();
|
||||||
assert (ptr2.get() != 0);
|
assert (ptr2.get() != 0);
|
||||||
|
|
||||||
// cast the other way round must fail
|
// cast the other way round must fail
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// TimerTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -63,7 +63,6 @@ void TimerTest::testTimer()
|
||||||
TimerCallback<TimerTest> tc(*this, &TimerTest::onTimer);
|
TimerCallback<TimerTest> tc(*this, &TimerTest::onTimer);
|
||||||
sw.start();
|
sw.start();
|
||||||
t.start(tc);
|
t.start(tc);
|
||||||
/***
|
|
||||||
_event.wait();
|
_event.wait();
|
||||||
sw.stop();
|
sw.stop();
|
||||||
assert (sw.elapsed() >= 90000 && sw.elapsed() < 150000);
|
assert (sw.elapsed() >= 90000 && sw.elapsed() < 150000);
|
||||||
|
@ -75,7 +74,6 @@ void TimerTest::testTimer()
|
||||||
_event.wait();
|
_event.wait();
|
||||||
sw.stop();
|
sw.stop();
|
||||||
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000);
|
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000);
|
||||||
***/
|
|
||||||
t.stop();
|
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.
|
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.
|
building the libraries.
|
||||||
|
|
||||||
--
|
--
|
||||||
$Id: //poco/1.2/dist/NEWS#4 $
|
$Id: //poco/1.2/dist/NEWS#5 $
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Application.h
|
// 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
|
// Library: Util
|
||||||
// Package: Application
|
// Package: Application
|
||||||
|
@ -418,7 +418,7 @@ inline Poco::Timespan Application::uptime() const
|
||||||
#define POCO_APP_MAIN(App) \
|
#define POCO_APP_MAIN(App) \
|
||||||
int wmain(int argc, wchar_t** argv) \
|
int wmain(int argc, wchar_t** argv) \
|
||||||
{ \
|
{ \
|
||||||
AutoPtr<SampleApp> pApp = new App; \
|
AutoPtr<App> pApp = new App; \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
pApp->init(argc, argv); \
|
pApp->init(argc, argv); \
|
||||||
|
@ -434,7 +434,7 @@ inline Poco::Timespan Application::uptime() const
|
||||||
#define POCO_APP_MAIN(App) \
|
#define POCO_APP_MAIN(App) \
|
||||||
int main(int argc, char** argv) \
|
int main(int argc, char** argv) \
|
||||||
{ \
|
{ \
|
||||||
AutoPtr<SampleApp> pApp = new App; \
|
AutoPtr<App> pApp = new App; \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
pApp->init(argc, argv); \
|
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
|
// 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
|
// Library: XML
|
||||||
// Package: DOM
|
// Package: DOM
|
||||||
|
@ -209,6 +209,9 @@ public:
|
||||||
/// are not of type ID unless so defined. Implementations that do
|
/// are not of type ID unless so defined. Implementations that do
|
||||||
/// not know whether attributes are of type ID or not are expected to
|
/// not know whether attributes are of type ID or not are expected to
|
||||||
/// return null. This implementation therefore returns null.
|
/// return null. This implementation therefore returns null.
|
||||||
|
///
|
||||||
|
/// See also the non-standard two argument variant of getElementById()
|
||||||
|
/// and getElementByIdNS().
|
||||||
|
|
||||||
// DocumentEvent
|
// DocumentEvent
|
||||||
Event* createEvent(const XMLString& eventType) const;
|
Event* createEvent(const XMLString& eventType) const;
|
||||||
|
@ -231,6 +234,18 @@ public:
|
||||||
///
|
///
|
||||||
/// This method is not part of the W3C Document Object Model.
|
/// 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:
|
protected:
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Element.h
|
// 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
|
// Library: XML
|
||||||
// Package: DOM
|
// Package: DOM
|
||||||
|
@ -79,6 +79,9 @@ public:
|
||||||
|
|
||||||
const XMLString& getAttribute(const XMLString& name) const;
|
const XMLString& getAttribute(const XMLString& name) const;
|
||||||
/// Retrieves an attribute value by name.
|
/// 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);
|
void setAttribute(const XMLString& name, const XMLString& value);
|
||||||
/// Adds a new attribute. If an attribute with that name is already present
|
/// Adds a new attribute. If an attribute with that name is already present
|
||||||
|
@ -127,6 +130,9 @@ public:
|
||||||
// DOM Level 2
|
// DOM Level 2
|
||||||
const XMLString& getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const;
|
const XMLString& getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||||
/// Retrieves an attribute value by name.
|
/// 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);
|
void setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value);
|
||||||
/// Adds a new attribute. If an attribute with that name
|
/// Adds a new attribute. If an attribute with that name
|
||||||
|
@ -177,7 +183,19 @@ public:
|
||||||
/// or null if such an element does not exist.
|
/// or null if such an element does not exist.
|
||||||
///
|
///
|
||||||
/// This method is an extension to the W3C Document Object Model.
|
/// 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
|
// Node
|
||||||
const XMLString& nodeName() const;
|
const XMLString& nodeName() const;
|
||||||
NamedNodeMap* attributes() const;
|
NamedNodeMap* attributes() const;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DOMParser.cpp
|
// DOMParser.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/XML/src/DOMParser.cpp#1 $
|
// $Id: //poco/1.2/XML/src/DOMParser.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: DOM
|
// Package: DOM
|
||||||
|
@ -54,6 +54,8 @@ DOMParser::DOMParser(NamePool* pNamePool):
|
||||||
_whitespace(true)
|
_whitespace(true)
|
||||||
{
|
{
|
||||||
if (_pNamePool) _pNamePool->duplicate();
|
if (_pNamePool) _pNamePool->duplicate();
|
||||||
|
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
|
||||||
|
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Document.cpp
|
// Document.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/XML/src/Document.cpp#1 $
|
// $Id: //poco/1.2/XML/src/Document.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: DOM
|
// 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
|
} } // namespace Poco::XML
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Element.cpp
|
// Element.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/XML/src/Element.cpp#1 $
|
// $Id: //poco/1.2/XML/src/Element.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: DOM
|
// 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
|
// NamespaceStrategy.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#1 $
|
// $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: XML
|
// Package: XML
|
||||||
|
@ -184,15 +184,19 @@ void NamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar*
|
||||||
const XMLChar* attrValue = *atts++;
|
const XMLChar* attrValue = *atts++;
|
||||||
XMLString attrURI;
|
XMLString attrURI;
|
||||||
XMLString attrLocal;
|
XMLString attrLocal;
|
||||||
XMLString attrPrefix;
|
XMLString attrQName;
|
||||||
splitName(attrName, attrURI, attrLocal, attrPrefix);
|
splitName(attrName, attrURI, attrLocal, attrQName);
|
||||||
attributes.addAttribute(attrURI, attrLocal, attrPrefix, CDATA, attrValue, i < specifiedCount);
|
if (!attrQName.empty()) attrQName.append(":");
|
||||||
|
attrQName.append(attrLocal);
|
||||||
|
attributes.addAttribute(attrURI, attrLocal, attrQName, CDATA, attrValue, i < specifiedCount);
|
||||||
}
|
}
|
||||||
XMLString uri;
|
XMLString uri;
|
||||||
XMLString local;
|
XMLString local;
|
||||||
XMLString prefix;
|
XMLString qname;
|
||||||
splitName(name, uri, local, prefix);
|
splitName(name, uri, local, qname);
|
||||||
pContentHandler->startElement(uri, local, prefix, attributes);
|
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 uri;
|
||||||
XMLString local;
|
XMLString local;
|
||||||
XMLString prefix;
|
XMLString qname;
|
||||||
splitName(name, uri, local, prefix);
|
splitName(name, uri, local, qname);
|
||||||
pContentHandler->endElement(uri, local, prefix);
|
if (!qname.empty()) qname.append(":");
|
||||||
|
qname.append(local);
|
||||||
|
pContentHandler->endElement(uri, local, qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DocumentTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// 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()
|
void DocumentTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -222,6 +303,8 @@ CppUnit::Test* DocumentTest::suite()
|
||||||
CppUnit_addTest(pSuite, DocumentTest, testImportDeep);
|
CppUnit_addTest(pSuite, DocumentTest, testImportDeep);
|
||||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagName);
|
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagName);
|
||||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagNameNS);
|
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagNameNS);
|
||||||
|
CppUnit_addTest(pSuite, DocumentTest, testElementById);
|
||||||
|
CppUnit_addTest(pSuite, DocumentTest, testElementByIdNS);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DocumentTest.h
|
// 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.
|
// Definition of the DocumentTest class.
|
||||||
//
|
//
|
||||||
|
@ -51,6 +51,8 @@ public:
|
||||||
void testImportDeep();
|
void testImportDeep();
|
||||||
void testElementsByTagName();
|
void testElementsByTagName();
|
||||||
void testElementsByTagNameNS();
|
void testElementsByTagNameNS();
|
||||||
|
void testElementById();
|
||||||
|
void testElementByIdNS();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ParserWriterTest.cpp
|
// 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.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
using Poco::XML::DOMParser;
|
using Poco::XML::DOMParser;
|
||||||
using Poco::XML::DOMWriter;
|
using Poco::XML::DOMWriter;
|
||||||
|
using Poco::XML::XMLReader;
|
||||||
using Poco::XML::XMLWriter;
|
using Poco::XML::XMLWriter;
|
||||||
using Poco::XML::Document;
|
using Poco::XML::Document;
|
||||||
using Poco::XML::AutoPtr;
|
using Poco::XML::AutoPtr;
|
||||||
|
@ -66,6 +67,7 @@ void ParserWriterTest::testParseWriteXHTML()
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
|
|
||||||
DOMParser parser;
|
DOMParser parser;
|
||||||
|
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||||
DOMWriter writer;
|
DOMWriter writer;
|
||||||
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
||||||
writer.writeNode(ostr, pDoc);
|
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()
|
void ParserWriterTest::testParseWriteWSDL()
|
||||||
{
|
{
|
||||||
std::istringstream istr(WSDL);
|
std::istringstream istr(WSDL);
|
||||||
|
@ -82,6 +99,7 @@ void ParserWriterTest::testParseWriteWSDL()
|
||||||
|
|
||||||
DOMParser parser;
|
DOMParser parser;
|
||||||
parser.setFeature(DOMParser::FEATURE_WHITESPACE, false);
|
parser.setFeature(DOMParser::FEATURE_WHITESPACE, false);
|
||||||
|
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||||
DOMWriter writer;
|
DOMWriter writer;
|
||||||
writer.setOptions(XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
|
writer.setOptions(XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
|
||||||
writer.setNewLine(XMLWriter::NEWLINE_LF);
|
writer.setNewLine(XMLWriter::NEWLINE_LF);
|
||||||
|
@ -109,6 +127,7 @@ CppUnit::Test* ParserWriterTest::suite()
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ParserWriterTest");
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ParserWriterTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
||||||
|
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML2);
|
||||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteWSDL);
|
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteWSDL);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
@ -136,6 +155,27 @@ const std::string ParserWriterTest::XHTML =
|
||||||
"</ns1:html>";
|
"</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 =
|
const std::string ParserWriterTest::WSDL =
|
||||||
"<!-- WSDL description of the Google Web APIs.\n"
|
"<!-- WSDL description of the Google Web APIs.\n"
|
||||||
" The Google Web APIs are in beta release. All interfaces are subject to\n"
|
" The Google Web APIs are in beta release. All interfaces are subject to\n"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ParserWriterTest.h
|
// 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.
|
// Definition of the ParserWriterTest class.
|
||||||
//
|
//
|
||||||
|
@ -47,6 +47,7 @@ public:
|
||||||
~ParserWriterTest();
|
~ParserWriterTest();
|
||||||
|
|
||||||
void testParseWriteXHTML();
|
void testParseWriteXHTML();
|
||||||
|
void testParseWriteXHTML2();
|
||||||
void testParseWriteWSDL();
|
void testParseWriteWSDL();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
|
@ -56,6 +57,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string XHTML;
|
static const std::string XHTML;
|
||||||
|
static const std::string XHTML2;
|
||||||
static const std::string WSDL;
|
static const std::string WSDL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче