checkout working scheduler
diff --git a/test/test-event-scheduler.cc b/test/test-event-scheduler.cc
index b827296..4642d95 100644
--- a/test/test-event-scheduler.cc
+++ b/test/test-event-scheduler.cc
@@ -37,17 +37,14 @@
{
SchedulerPtr scheduler(new Scheduler());
IntervalGeneratorPtr generator(new SimpleIntervalGenerator(0.2));
- IntervalGeneratorPtr randomGen(new RandomIntervalGenerator(0.05, 0.5));
string tag1 = "hello";
string tag2 = "world";
string tag3 = "period";
- string tag4 = "haha";
TaskPtr task1(new OneTimeTask(boost::bind(func, tag1), tag1, scheduler, 0.5));
TaskPtr task2(new OneTimeTask(boost::bind(func, tag2), tag2, scheduler, 0.5));
TaskPtr task3(new PeriodicTask(boost::bind(func, tag3), tag3, scheduler, generator));
- TaskPtr task4(new PeriodicTask(boost::bind(func, tag4), tag4, scheduler, randomGen, 5));
scheduler->start();
scheduler->addTask(task1);
@@ -72,14 +69,11 @@
usleep(100000);
scheduler->deleteTask(bind(matcher, _1));
BOOST_CHECK_EQUAL(scheduler->size(), 1);
- usleep(500000);
-
- scheduler->addTask(task4);
- usleep(500000);
+ usleep(1000000);
scheduler->shutdown();
- int hello = 0, world = 0, period = 0, haha = 0;
+ int hello = 0, world = 0, period = 0;
map<string, int>::iterator it;
it = table.find(tag1);
@@ -98,20 +92,12 @@
period = it->second;
}
- it = table.find(tag4);
- if (it != table.end())
- {
- haha = it->second;
- }
-
// added four times, canceled once before invoking callback
BOOST_CHECK_EQUAL(hello, 3);
// added two times, canceled once by matcher before invoking callback
BOOST_CHECK_EQUAL(world, 1);
// invoked every 0.2 seconds before deleted by matcher
BOOST_CHECK_EQUAL(period, static_cast<int>((0.6 + 0.6 + 0.4 + 0.2 + 0.1) / 0.2));
- // should be invoked 5 times exactly
- BOOST_CHECK_EQUAL(haha, 5);
}