A Discrete-Event Network Simulator
API
event-garbage-collector-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) 2007 INESC Porto
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: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
19 */
20
21#include "ns3/test.h"
22#include "ns3/event-garbage-collector.h"
23
37namespace ns3 {
38
39namespace tests {
40
41
47{
50
53
54public:
55
60 virtual void DoRun (void);
61};
62
64 : TestCase ("EventGarbageCollector"), m_counter (0), m_events (0)
65{}
66
68{}
69
70void
72{
73 m_counter++;
74 if (m_counter == 50)
75 {
76 // this should cause the remaining (50) events to be cancelled
77 delete m_events;
78 m_events = 0;
79 }
80}
81
83{
85
86 for (int n = 0; n < 100; n++)
87 {
91 this));
92 }
97}
98
104{
105public:
107 : TestSuite ("event-garbage-collector")
108 {
110 }
111};
112
118
119
120} // namespace tests
121
122} // namespace ns3
123
An object that tracks scheduled events and automatically cancels them when it is destroyed.
void Track(EventId event)
Tracks a new event.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
virtual void DoRun(void)
Implementation to actually run this TestCase.
void EventGarbageCollectorCallback()
Callback to record event invocations.
EventGarbageCollector * m_events
Object under test.
int m_counter
Counter to trigger deletion of events.
static EventGarbageCollectorTestSuite g_eventGarbageCollectorTestSuite
EventGarbageCollectorTestSuite instance variable.
#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:240
Every class exported by the ns3 library is enclosed in the ns3 namespace.