mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
trunk/branch integration: unit test integration
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// NotificationCenterTest.cpp
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/testsuite/src/NotificationCenterTest.cpp#2 $
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/NotificationCenterTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -70,26 +70,34 @@ void NotificationCenterTest::test1()
|
||||
|
||||
void NotificationCenterTest::test2()
|
||||
{
|
||||
NotificationCenter nc;
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
nc.postNotification(new Notification);
|
||||
assert (_set.size() == 1);
|
||||
assert (_set.find("handle1") != _set.end());
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
NotificationCenter nc;
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
assert (nc.hasObservers());
|
||||
assert (nc.countObservers() == 1);
|
||||
nc.postNotification(new Notification);
|
||||
assert (_set.size() == 1);
|
||||
assert (_set.find("handle1") != _set.end());
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
assert (!nc.hasObservers());
|
||||
assert (nc.countObservers() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NotificationCenterTest::test3()
|
||||
{
|
||||
NotificationCenter nc;
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
|
||||
nc.postNotification(new Notification);
|
||||
assert (_set.size() == 2);
|
||||
assert (_set.find("handle1") != _set.end());
|
||||
assert (_set.find("handle2") != _set.end());
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
|
||||
NotificationCenter nc;
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
|
||||
assert (nc.hasObservers());
|
||||
assert (nc.countObservers() == 2);
|
||||
nc.postNotification(new Notification);
|
||||
assert (_set.size() == 2);
|
||||
assert (_set.find("handle1") != _set.end());
|
||||
assert (_set.find("handle2") != _set.end());
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
|
||||
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
|
||||
assert (!nc.hasObservers());
|
||||
assert (nc.countObservers() == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user