trunk/branch integration: unit test integration

This commit is contained in:
Marian Krivos
2011-08-23 09:16:33 +00:00
parent fd733bcca4
commit 53eff41df8
48 changed files with 1939 additions and 697 deletions

View File

@@ -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);
}