A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
sample-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) 2009 University of Washington
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
*/
19
20
// An essential include is test.h
21
#include "ns3/test.h"
22
44
48
64
77
namespace
ns3
{
78
79
namespace
tests
{
80
81
86
class
SampleTestCase1
:
public
TestCase
87
{
88
public
:
90
SampleTestCase1
();
92
virtual
~SampleTestCase1
();
93
94
private
:
95
virtual
void
DoRun
(
void
);
96
};
97
99
SampleTestCase1::SampleTestCase1
()
100
:
TestCase
(
"Sample test case (does nothing)"
)
101
{}
102
107
SampleTestCase1::~SampleTestCase1
()
108
{}
109
114
void
115
SampleTestCase1::DoRun
(
void
)
116
{
117
// A wide variety of test macros are available in src/core/test.h
118
NS_TEST_ASSERT_MSG_EQ
(
true
,
true
,
"true doesn't equal true for some reason"
);
119
// Use this one for floating point comparisons
120
NS_TEST_ASSERT_MSG_EQ_TOL
(0.01, 0.01, 0.001,
"Numbers are not equal within tolerance"
);
121
}
122
129
class
SampleTestSuite
:
public
TestSuite
130
{
131
public
:
133
SampleTestSuite
();
134
};
135
136
SampleTestSuite::SampleTestSuite
()
137
:
TestSuite
(
"sample"
)
138
{
139
AddTestCase
(
new
SampleTestCase1
);
140
}
141
142
// Do not forget to allocate an instance of this TestSuite
147
static
SampleTestSuite
g_sampleTestSuite
;
148
149
150
}
// namespace tests
151
152
}
// namespace ns3
ns3::TestCase
encapsulates test code
Definition:
test.h:994
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1188
ns3::tests::SampleTestCase1
This is an example TestCase.
Definition:
sample-test-suite.cc:87
ns3::tests::SampleTestCase1::DoRun
virtual void DoRun(void)
This method is the pure virtual method from class TestCase that every TestCase must implement.
Definition:
sample-test-suite.cc:115
ns3::tests::SampleTestCase1::SampleTestCase1
SampleTestCase1()
Constructor.
Definition:
sample-test-suite.cc:99
ns3::tests::SampleTestCase1::~SampleTestCase1
virtual ~SampleTestCase1()
Destructor.
Definition:
sample-test-suite.cc:107
ns3::tests::SampleTestSuite
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Definition:
sample-test-suite.cc:130
ns3::tests::SampleTestSuite::SampleTestSuite
SampleTestSuite()
Constructor.
Definition:
sample-test-suite.cc:136
ns3::tests::g_sampleTestSuite
static SampleTestSuite g_sampleTestSuite
SampleTestSuite instance variable.
Definition:
sample-test-suite.cc:147
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition:
test.h:141
NS_TEST_ASSERT_MSG_EQ_TOL
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition:
test.h:323
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
test-ns3.tests
tests
Definition:
test-ns3.py:2134
src
core
test
sample-test-suite.cc
Generated on Tue Feb 6 2024 19:21:17 for ns-3 by
1.9.1