mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 19:25:53 +02:00
add test for c2edf4470f
This commit is contained in:
@@ -109,6 +109,36 @@ void TimerTest::testScheduleAtFixedRate()
|
||||
}
|
||||
|
||||
|
||||
void TimerTest::testCancel()
|
||||
{
|
||||
Timer timer;
|
||||
|
||||
Timestamp time;
|
||||
|
||||
TimerTask::Ptr pTask = new TimerTaskAdapter<TimerTest>(*this, &TimerTest::onTimer);
|
||||
|
||||
assert (pTask->lastExecution() == 0);
|
||||
|
||||
timer.scheduleAtFixedRate(pTask, 5000, 5000);
|
||||
|
||||
pTask->cancel();
|
||||
assert (pTask->isCancelled());
|
||||
|
||||
try
|
||||
{
|
||||
timer.scheduleAtFixedRate(pTask, 5000, 5000);
|
||||
fail("must not reschedule a cancelled task");
|
||||
}
|
||||
catch (Poco::IllegalStateException&)
|
||||
{
|
||||
}
|
||||
catch (Poco::Exception&)
|
||||
{
|
||||
fail("bad exception thrown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TimerTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -133,6 +163,7 @@ CppUnit::Test* TimerTest::suite()
|
||||
CppUnit_addTest(pSuite, TimerTest, testSchedule);
|
||||
CppUnit_addTest(pSuite, TimerTest, testScheduleInterval);
|
||||
CppUnit_addTest(pSuite, TimerTest, testScheduleAtFixedRate);
|
||||
CppUnit_addTest(pSuite, TimerTest, testCancel);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ public:
|
||||
void testSchedule();
|
||||
void testScheduleInterval();
|
||||
void testScheduleAtFixedRate();
|
||||
void testCancel();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
Reference in New Issue
Block a user