A Discrete-Event Network Simulator
API
simulator-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "ns3/test.h"
21 #include "ns3/simulator.h"
22 #include "ns3/list-scheduler.h"
23 #include "ns3/heap-scheduler.h"
24 #include "ns3/map-scheduler.h"
25 #include "ns3/calendar-scheduler.h"
26 
27 using namespace ns3;
28 
30 {
31 public:
32  SimulatorEventsTestCase (ObjectFactory schedulerFactory);
33  virtual void DoRun (void);
34  void EventA (int a);
35  void EventB (int b);
36  void EventC (int c);
37  void EventD (int d);
38  void Eventfoo0 (void);
39  uint64_t NowUs (void);
40  void destroy (void);
41  bool m_b;
42  bool m_a;
43  bool m_c;
44  bool m_d;
46  bool m_destroy;
49 };
50 
52  : TestCase ("Check that basic event handling is working with " +
53  schedulerFactory.GetTypeId ().GetName ()),
54  m_schedulerFactory (schedulerFactory)
55 {}
56 uint64_t
58 {
59  uint64_t ns = Now ().GetNanoSeconds ();
60  return ns / 1000;
61 }
62 
63 void
65 {
66  NS_UNUSED (a);
67  m_a = false;
68 }
69 
70 void
72 {
73  if (b != 2 || NowUs () != 11)
74  {
75  m_b = false;
76  }
77  else
78  {
79  m_b = true;
80  }
81  Simulator::Remove (m_idC);
82  Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::EventD, this, 4);
83 }
84 
85 void
87 {
88  NS_UNUSED (c);
89  m_c = false;
90 }
91 
92 void
94 {
95  if (d != 4 || NowUs () != (11 + 10))
96  {
97  m_d = false;
98  }
99  else
100  {
101  m_d = true;
102  }
103 }
104 
105 void
107 {}
108 
109 void
111 {
112  if (m_destroyId.IsExpired ())
113  {
114  m_destroy = true;
115  }
116 }
117 void
119 {
120  m_a = true;
121  m_b = false;
122  m_c = true;
123  m_d = false;
124 
125  Simulator::SetScheduler (m_schedulerFactory);
126 
127  EventId a = Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::EventA, this, 1);
128  Simulator::Schedule (MicroSeconds (11), &SimulatorEventsTestCase::EventB, this, 2);
129  m_idC = Simulator::Schedule (MicroSeconds (12), &SimulatorEventsTestCase::EventC, this, 3);
130 
131  NS_TEST_EXPECT_MSG_EQ (!m_idC.IsExpired (), true, "");
132  NS_TEST_EXPECT_MSG_EQ (!a.IsExpired (), true, "");
133  Simulator::Cancel (a);
134  NS_TEST_EXPECT_MSG_EQ (a.IsExpired (), true, "");
135  Simulator::Run ();
136  NS_TEST_EXPECT_MSG_EQ (m_a, true, "Event A did not run ?");
137  NS_TEST_EXPECT_MSG_EQ (m_b, true, "Event B did not run ?");
138  NS_TEST_EXPECT_MSG_EQ (m_c, true, "Event C did not run ?");
139  NS_TEST_EXPECT_MSG_EQ (m_d, true, "Event D did not run ?");
140 
141  EventId anId = Simulator::ScheduleNow (&SimulatorEventsTestCase::Eventfoo0, this);
142  EventId anotherId = anId;
143  NS_TEST_EXPECT_MSG_EQ (!(anId.IsExpired () || anotherId.IsExpired ()), true, "Event should not have expired yet.");
144 
145  Simulator::Remove (anId);
146  NS_TEST_EXPECT_MSG_EQ (anId.IsExpired (), true, "Event was removed: it is now expired");
147  NS_TEST_EXPECT_MSG_EQ (anotherId.IsExpired (), true, "Event was removed: it is now expired");
148 
149  m_destroy = false;
150  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
151  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
152  m_destroyId.Cancel ();
153  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event was canceled: should have expired now");
154 
155  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
156  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
157  Simulator::Remove (m_destroyId);
158  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event was canceled: should have expired now");
159 
160  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
161  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
162 
163  Simulator::Run ();
164  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
165  NS_TEST_EXPECT_MSG_EQ (!m_destroy, true, "Event should not have run");
166 
167  Simulator::Destroy ();
168  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event should have expired now");
169  NS_TEST_EXPECT_MSG_EQ (m_destroy, true, "Event should have run");
170 }
171 
173 {
174 public:
176  // only here for testing of Ptr<>
177  void Ref (void) const
178  {}
179  void Unref (void) const
180  {}
181 
182 private:
183  virtual void DoRun (void);
184 
185  /* *NS_CHECK_STYLE_OFF* */
186  void bar0 (void) {}
187  void bar1 (int) {}
188  void bar2 (int, int) {}
189  void bar3 (int, int, int) {}
190  void bar4 (int, int, int, int) {}
191  void bar5 (int, int, int, int, int) {}
192  void baz1 (int &) {}
193  void baz2 (int &, int &) {}
194  void baz3 (int &, int &, int &) {}
195  void baz4 (int &, int &, int &, int &) {}
196  void baz5 (int &, int &, int &, int &, int &) {}
197  void cbaz1 (const int &) {}
198  void cbaz2 (const int &, const int &) {}
199  void cbaz3 (const int &, const int &, const int &) {}
200  void cbaz4 (const int &, const int &, const int &, const int &) {}
201  void cbaz5 (const int &, const int &, const int &, const int &, const int &) {}
202 
203  void bar0c (void) const {}
204  void bar1c (int) const {}
205  void bar2c (int, int) const {}
206  void bar3c (int, int, int) const {}
207  void bar4c (int, int, int, int) const {}
208  void bar5c (int, int, int, int, int) const {}
209  void baz1c (int &) const {}
210  void baz2c (int &, int &) const {}
211  void baz3c (int &, int &, int &) const {}
212  void baz4c (int &, int &, int &, int &) const {}
213  void baz5c (int &, int &, int &, int &, int &) const {}
214  void cbaz1c (const int &) const {}
215  void cbaz2c (const int &, const int &) const {}
216  void cbaz3c (const int &, const int &, const int &) const {}
217  void cbaz4c (const int &, const int &, const int &, const int &) const {}
218  void cbaz5c (const int &, const int &, const int &, const int &, const int &) const {}
219  /* *NS_CHECK_STYLE_ON* */
220 
221 };
222 
223 static void foo0 (void)
224 {}
225 static void foo1 (int)
226 {}
227 static void foo2 (int, int)
228 {}
229 static void foo3 (int, int, int)
230 {}
231 static void foo4 (int, int, int, int)
232 {}
233 static void foo5 (int, int, int, int, int)
234 {}
235 static void ber1 (int &)
236 {}
237 static void ber2 (int &, int &)
238 {}
239 static void ber3 (int &, int &, int &)
240 {}
241 static void ber4 (int &, int &, int &, int &)
242 {}
243 static void ber5 (int &, int &, int &, int &, int &)
244 {}
245 static void cber1 (const int &)
246 {}
247 static void cber2 (const int &, const int &)
248 {}
249 static void cber3 (const int &, const int &, const int &)
250 {}
251 static void cber4 (const int &, const int &, const int &, const int &)
252 {}
253 static void cber5 (const int &, const int &, const int &, const int &, const int &)
254 {}
255 
257  : TestCase ("Check that all templates are instantiated correctly. This is a compilation test, it cannot fail at runtime.")
258 {}
259 void
261 {
262  // Test schedule of const methods
263  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0c, this);
264  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1c, this, 0);
265  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2c, this, 0, 0);
266  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
267  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
268  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
269  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz1c, this, 0);
270  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
271  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
272  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
273  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
274  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0c, this);
275  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1c, this, 0);
276  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2c, this, 0, 0);
277  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
278  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
279  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
280  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz1c, this, 0);
281  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
282  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
283  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
284  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
285  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0c, this);
286  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1c, this, 0);
287  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2c, this, 0, 0);
288  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
289  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
290  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
291  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz1c, this, 0);
292  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
293  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
294  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
295  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
296  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz1c, this, 0);
297  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz2c, this, 0, 0);
298  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
299  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
300  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
301  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz1c, this, 0);
302  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz2c, this, 0, 0);
303  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
304  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
305  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
306  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz1c, this, 0);
307  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz2c, this, 0, 0);
308  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
309  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
310  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
311 
312  // Test of schedule const methods with Ptr<> pointers
314  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
315  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
316  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
317  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
318  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
320  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
321  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
322  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
323  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
324  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
325  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0c, Ptr<const SimulatorTemplateTestCase> (this));
326  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
327  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
328  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
329  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
330  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
331 
332 
333  // Test schedule of raw functions
334  Simulator::Schedule (Seconds (0.0), &foo0);
335  Simulator::Schedule (Seconds (0.0), &foo1, 0);
336  Simulator::Schedule (Seconds (0.0), &foo2, 0, 0);
337  Simulator::Schedule (Seconds (0.0), &foo3, 0, 0, 0);
338  Simulator::Schedule (Seconds (0.0), &foo4, 0, 0, 0, 0);
339  Simulator::Schedule (Seconds (0.0), &foo5, 0, 0, 0, 0, 0);
340  Simulator::Schedule (Seconds (0.0), &cber1, 0);
341  Simulator::Schedule (Seconds (0.0), &cber2, 0, 0);
342  Simulator::Schedule (Seconds (0.0), &cber3, 0, 0, 0);
343  Simulator::Schedule (Seconds (0.0), &cber4, 0, 0, 0, 0);
344  Simulator::Schedule (Seconds (0.0), &cber5, 0, 0, 0, 0, 0);
345  Simulator::ScheduleNow (&foo0);
346  Simulator::ScheduleNow (&foo1, 0);
347  Simulator::ScheduleNow (&foo2, 0, 0);
348  Simulator::ScheduleNow (&foo3, 0, 0, 0);
349  Simulator::ScheduleNow (&foo4, 0, 0, 0, 0);
350  Simulator::ScheduleNow (&foo5, 0, 0, 0, 0, 0);
351  Simulator::ScheduleNow (&cber1, 0);
352  Simulator::ScheduleNow (&cber2, 0, 0);
353  Simulator::ScheduleNow (&cber3, 0, 0, 0);
354  Simulator::ScheduleNow (&cber4, 0, 0, 0, 0);
355  Simulator::ScheduleNow (&cber5, 0, 0, 0, 0, 0);
356  Simulator::ScheduleDestroy (&foo0);
357  Simulator::ScheduleDestroy (&foo1, 0);
358  Simulator::ScheduleDestroy (&foo2, 0, 0);
359  Simulator::ScheduleDestroy (&foo3, 0, 0, 0);
360  Simulator::ScheduleDestroy (&foo4, 0, 0, 0, 0);
361  Simulator::ScheduleDestroy (&foo5, 0, 0, 0, 0, 0);
362  Simulator::ScheduleDestroy (&cber1, 0);
363  Simulator::ScheduleDestroy (&cber2, 0, 0);
364  Simulator::ScheduleDestroy (&cber3, 0, 0, 0);
365  Simulator::ScheduleDestroy (&cber4, 0, 0, 0, 0);
366  Simulator::ScheduleDestroy (&cber5, 0, 0, 0, 0, 0);
367 
368 
369  // Test schedule of normal member methods
370  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0, this);
371  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1, this, 0);
372  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2, this, 0, 0);
373  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
374  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
375  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
376  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz1, this, 0);
377  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz2, this, 0, 0);
378  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
379  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
380  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
381  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0, this);
382  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1, this, 0);
383  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2, this, 0, 0);
384  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
385  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
386  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
387  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz1, this, 0);
388  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz2, this, 0, 0);
389  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
390  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
391  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
392  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0, this);
393  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1, this, 0);
394  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2, this, 0, 0);
395  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
396  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
397  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
398  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz1, this, 0);
399  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz2, this, 0, 0);
400  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
401  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
402  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
403 
404 
405  // test schedule of normal methods with Ptr<> pointers
406  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
407  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
408  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
409  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
410  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
411  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
412  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
413  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
414  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
415  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
416  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
417  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
418  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
419  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
420  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
421  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
422  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
423  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
424 
425 
426  // the code below does not compile, as expected.
427  //Simulator::Schedule (Seconds (0.0), &cber1, 0.0);
428 
429 
430  // This code appears to be duplicate test code.
431  Simulator::Schedule (Seconds (0.0), &ber1, 0);
432  Simulator::Schedule (Seconds (0.0), &ber2, 0, 0);
433  Simulator::Schedule (Seconds (0.0), &ber3, 0, 0, 0);
434  Simulator::Schedule (Seconds (0.0), &ber4, 0, 0, 0, 0);
435  Simulator::Schedule (Seconds (0.0), &ber5, 0, 0, 0, 0, 0);
436  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz1, this, 0);
437  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz2, this, 0, 0);
438  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
439  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
440  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
441  Simulator::ScheduleNow (&ber1, 0);
442  Simulator::ScheduleNow (&ber2, 0, 0);
443  Simulator::ScheduleNow (&ber3, 0, 0, 0);
444  Simulator::ScheduleNow (&ber4, 0, 0, 0, 0);
445  Simulator::ScheduleNow (&ber5, 0, 0, 0, 0, 0);
446  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz1, this, 0);
447  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz2, this, 0, 0);
448  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
449  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
450  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
451  Simulator::ScheduleDestroy (&ber1, 0);
452  Simulator::ScheduleDestroy (&ber2, 0, 0);
453  Simulator::ScheduleDestroy (&ber3, 0, 0, 0);
454  Simulator::ScheduleDestroy (&ber4, 0, 0, 0, 0);
455  Simulator::ScheduleDestroy (&ber5, 0, 0, 0, 0, 0);
456  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz1, this, 0);
457  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz2, this, 0, 0);
458  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
459  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
460  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
461 
462 
463  Simulator::Run ();
464  Simulator::Destroy ();
465 }
466 
468 {
469 public:
471  : TestSuite ("simulator")
472  {
473  ObjectFactory factory;
474  factory.SetTypeId (ListScheduler::GetTypeId ());
475 
476  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
477  factory.SetTypeId (MapScheduler::GetTypeId ());
478  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
479  factory.SetTypeId (HeapScheduler::GetTypeId ());
480  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
481  factory.SetTypeId (CalendarScheduler::GetTypeId ());
482  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
483  }
static void ber5(int &, int &, int &, int &, int &)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
static void cber4(const int &, const int &, const int &, const int &)
void bar4(int, int, int, int)
static void ber4(int &, int &, int &, int &)
void baz3(int &, int &, int &)
void baz5c(int &, int &, int &, int &, int &) const
static void foo5(int, int, int, int, int)
A suite of tests to run.
Definition: test.h:1343
static void cber5(const int &, const int &, const int &, const int &, const int &)
void baz5(int &, int &, int &, int &, int &)
void bar3c(int, int, int) const
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
SimulatorEventsTestCase(ObjectFactory schedulerFactory)
encapsulates test code
Definition: test.h:1153
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
void cbaz5c(const int &, const int &, const int &, const int &, const int &) const
static void foo0(void)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void cbaz3c(const int &, const int &, const int &) const
void baz3c(int &, int &, int &) const
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
static void ber3(int &, int &, int &)
static void foo3(int, int, int)
void baz4c(int &, int &, int &, int &) const
void bar5c(int, int, int, int, int) const
void bar4c(int, int, int, int) const
void cbaz5(const int &, const int &, const int &, const int &, const int &)
static void foo1(int)
static void ber1(int &)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:373
void baz4(int &, int &, int &, int &)
virtual void DoRun(void)
Implementation to actually run this TestCase.
static void cber3(const int &, const int &, const int &)
void bar5(int, int, int, int, int)
SimulatorTestSuite g_simulatorTestSuite
Instantiate subclasses of ns3::Object.
void baz2c(int &, int &) const
static void cber1(const int &)
An identifier for simulation events.
Definition: event-id.h:53
void cbaz4(const int &, const int &, const int &, const int &)
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
static void ber2(int &, int &)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
void cbaz1c(const int &) const
static void foo2(int, int)
static void cber2(const int &, const int &)
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1086
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
void cbaz2c(const int &, const int &) const
void cbaz3(const int &, const int &, const int &)
void cbaz2(const int &, const int &)
static void foo4(int, int, int, int)
void cbaz4c(const int &, const int &, const int &, const int &) const