20 #include "ns3/timer.h"
22 #include "ns3/simulator.h"
23 #include "ns3/nstime.h"
32 void bar3i (
int,
int,
int)
35 void bar4i (
int,
int,
int,
int)
38 void bar5i (
int,
int,
int,
int,
int)
41 void barcir (
const int &)
55 virtual void DoRun (
void);
58 TimerStateTestCase::TimerStateTestCase ()
59 :
TestCase (
"Check correct state transitions")
65 Timer timer =
Timer (Timer::CANCEL_ON_DESTROY);
70 NS_TEST_ASSERT_MSG_EQ (!timer.
IsRunning (),
true,
"");
71 NS_TEST_ASSERT_MSG_EQ (timer.
IsExpired (),
true,
"");
72 NS_TEST_ASSERT_MSG_EQ (!timer.
IsSuspended (),
true,
"");
73 NS_TEST_ASSERT_MSG_EQ (timer.
GetState (), Timer::EXPIRED,
"");
75 NS_TEST_ASSERT_MSG_EQ (timer.
IsRunning (),
true,
"");
76 NS_TEST_ASSERT_MSG_EQ (!timer.
IsExpired (),
true,
"");
77 NS_TEST_ASSERT_MSG_EQ (!timer.
IsSuspended (),
true,
"");
78 NS_TEST_ASSERT_MSG_EQ (timer.
GetState (), Timer::RUNNING,
"");
80 NS_TEST_ASSERT_MSG_EQ (!timer.
IsRunning (),
true,
"");
81 NS_TEST_ASSERT_MSG_EQ (!timer.
IsExpired (),
true,
"");
82 NS_TEST_ASSERT_MSG_EQ (timer.
IsSuspended (),
true,
"");
83 NS_TEST_ASSERT_MSG_EQ (timer.
GetState (), Timer::SUSPENDED,
"");
85 NS_TEST_ASSERT_MSG_EQ (timer.
IsRunning (),
true,
"");
86 NS_TEST_ASSERT_MSG_EQ (!timer.
IsExpired (),
true,
"");
87 NS_TEST_ASSERT_MSG_EQ (!timer.
IsSuspended (),
true,
"");
88 NS_TEST_ASSERT_MSG_EQ (timer.
GetState (), Timer::RUNNING,
"");
90 NS_TEST_ASSERT_MSG_EQ (!timer.
IsRunning (),
true,
"");
91 NS_TEST_ASSERT_MSG_EQ (timer.
IsExpired (),
true,
"");
92 NS_TEST_ASSERT_MSG_EQ (!timer.
IsSuspended (),
true,
"");
93 NS_TEST_ASSERT_MSG_EQ (timer.
GetState (), Timer::EXPIRED,
"");
100 virtual void DoRun (
void);
105 void baz2i (
int,
int)
108 void baz3i (
int,
int,
int)
111 void baz4i (
int,
int,
int,
int)
114 void baz5i (
int,
int,
int,
int,
int)
117 void baz6i (
int,
int,
int,
int,
int,
int)
120 void bazcir (
const int&)
129 void bazcip (
const int *)
134 TimerTemplateTestCase::TimerTemplateTestCase ()
135 :
TestCase (
"Check that template magic is working")
142 Timer timer =
Timer (Timer::CANCEL_ON_DESTROY);
169 timer.
SetFunction (&TimerTemplateTestCase::bazi,
this);
171 timer.
SetFunction (&TimerTemplateTestCase::bazir,
this);
173 timer.
SetFunction (&TimerTemplateTestCase::bazcir,
this);
188 timer.
SetFunction (&TimerTemplateTestCase::baz2i,
this);
190 timer.
SetFunction (&TimerTemplateTestCase::baz3i,
this);
192 timer.
SetFunction (&TimerTemplateTestCase::baz4i,
this);
194 timer.
SetFunction (&TimerTemplateTestCase::baz5i,
this);
201 Simulator::Destroy ();
208 Simulator::Destroy ();
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
virtual void DoRun(void)
Implementation to actually run this test case.
bool IsRunning(void) const
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
void SetDelay(const Time &delay)
enum Timer::State GetState(void) const
virtual void DoRun(void)
Implementation to actually run this test case.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
bool IsExpired(void) const
bool IsSuspended(void) const