4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Jens Moedeker <jens.moedeker@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief TimerEventProxy.test non-inline non-template implementation */
26 //#include "TimerEventProxy.test.hh"
27 //#include "TimerEventProxy.test.ih"
30 #include "TimerEventProxy.hh"
31 #include "Scheduler.hh"
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
35 #include <boost/random.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
43 void handler( senf::ClockService::clock_type time, int const &id)
48 void run(senf::ClockService::clock_type t) {
49 senf::scheduler::TimerEvent timeout(
50 "test-timeout", &senf::scheduler::terminate, senf::scheduler::now() + t);
51 senf::scheduler::process();
56 SENF_AUTO_UNIT_TEST(timerEventProxy)
58 // // abort on watchdog timeout
59 // senf::scheduler::watchdogAbort( true);
60 // senf::scheduler::watchdogTimeout(5000);
62 senf::ClockService::clock_type t (senf::ClockService::now());
64 senf::scheduler::TimerEventProxy<int> timers ("unit-test");
66 // timers.add( t + senf::ClockService::milliseconds(10000), 0 , &handler);
67 timers.add( t + senf::ClockService::milliseconds(800), 4, &handler);
68 timers.add( t + senf::ClockService::milliseconds(200), 1, &handler);
69 BOOST_CHECK( timers.remove( 4));
70 BOOST_CHECK(! timers.remove( 4));
71 timers.add( t + senf::ClockService::milliseconds(700), 2, &handler);
73 BOOST_CHECK_EQUAL( timers.timeout(1), t + senf::ClockService::milliseconds(200));
74 BOOST_CHECK_EQUAL( timers.timeout(2), t + senf::ClockService::milliseconds(700));
75 BOOST_CHECK_EQUAL( timers.timeout(4), 0);
77 run( senf::ClockService::milliseconds( 2000));
79 BOOST_CHECK( mask == 3);
84 ///////////////////////////////cc.e////////////////////////////////////////
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"