Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Scheduler / TimerEventProxy.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2010
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>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief TimerEventProxy.test non-inline non-template implementation */
25
26 //#include "TimerEventProxy.test.hh"
27 //#include "TimerEventProxy.test.ih"
28
29 // Custom includes
30 #include "TimerEventProxy.hh"
31 #include "Scheduler.hh"
32
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
35 #include <boost/random.hpp>
36
37 #define prefix_
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 namespace {
40
41     int mask = 0;
42
43     void handler( senf::ClockService::clock_type time, int const &id)
44     {
45         mask = mask + id;
46     }
47
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();
52     }
53
54 }
55
56 SENF_AUTO_UNIT_TEST(timerEventProxy)
57 {
58 //    // abort on watchdog timeout
59 //    senf::scheduler::watchdogAbort( true);
60 //    senf::scheduler::watchdogTimeout(5000);
61
62     senf::ClockService::clock_type t (senf::ClockService::now());
63     {
64         senf::scheduler::TimerEventProxy<int> timers ("unit-test");
65
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);
72
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);
76
77         run( senf::ClockService::milliseconds( 2000));
78
79         BOOST_CHECK( mask == 3);
80     }
81 }
82
83
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 #undef prefix_
86
87
88 // Local Variables:
89 // mode: c++
90 // fill-column: 100
91 // comment-column: 40
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"
96 // End: