mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-18 03:29:47 +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()
|
void TimerTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -133,6 +163,7 @@ CppUnit::Test* TimerTest::suite()
|
|||||||
CppUnit_addTest(pSuite, TimerTest, testSchedule);
|
CppUnit_addTest(pSuite, TimerTest, testSchedule);
|
||||||
CppUnit_addTest(pSuite, TimerTest, testScheduleInterval);
|
CppUnit_addTest(pSuite, TimerTest, testScheduleInterval);
|
||||||
CppUnit_addTest(pSuite, TimerTest, testScheduleAtFixedRate);
|
CppUnit_addTest(pSuite, TimerTest, testScheduleAtFixedRate);
|
||||||
|
CppUnit_addTest(pSuite, TimerTest, testCancel);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ public:
|
|||||||
void testSchedule();
|
void testSchedule();
|
||||||
void testScheduleInterval();
|
void testScheduleInterval();
|
||||||
void testScheduleAtFixedRate();
|
void testScheduleAtFixedRate();
|
||||||
|
void testCancel();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
Reference in New Issue
Block a user