A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
sample-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 University of Washington
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
*/
18
19
// An essential include is test.h
20
#include "ns3/test.h"
21
43
47
63
75
namespace
ns3
76
{
77
78
namespace
tests
79
{
80
85
class
SampleTestCase1
:
public
TestCase
86
{
87
public
:
89
SampleTestCase1
();
91
~SampleTestCase1
()
override
;
92
93
private
:
94
void
DoRun
()
override
;
95
};
96
98
SampleTestCase1::SampleTestCase1
()
99
:
TestCase
(
"Sample test case (does nothing)"
)
100
{
101
}
102
107
SampleTestCase1::~SampleTestCase1
()
108
{
109
}
110
115
void
116
SampleTestCase1::DoRun
()
117
{
118
// A wide variety of test macros are available in src/core/test.h
119
NS_TEST_ASSERT_MSG_EQ
(
true
,
true
,
"true doesn't equal true for some reason"
);
120
// Use this one for floating point comparisons
121
NS_TEST_ASSERT_MSG_EQ_TOL
(0.01, 0.01, 0.001,
"Numbers are not equal within tolerance"
);
122
}
123
130
class
SampleTestSuite
:
public
TestSuite
131
{
132
public
:
134
SampleTestSuite
();
135
};
136
137
SampleTestSuite::SampleTestSuite
()
138
:
TestSuite
(
"sample"
)
139
{
140
AddTestCase
(
new
SampleTestCase1
);
141
}
142
143
// Do not forget to allocate an instance of this TestSuite
148
static
SampleTestSuite
g_sampleTestSuite
;
149
150
}
// namespace tests
151
152
}
// namespace ns3
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::tests::SampleTestCase1
This is an example TestCase.
Definition:
sample-test-suite.cc:86
ns3::tests::SampleTestCase1::SampleTestCase1
SampleTestCase1()
Constructor.
Definition:
sample-test-suite.cc:98
ns3::tests::SampleTestCase1::~SampleTestCase1
~SampleTestCase1() override
Destructor.
Definition:
sample-test-suite.cc:107
ns3::tests::SampleTestCase1::DoRun
void DoRun() override
This method is the pure virtual method from class TestCase that every TestCase must implement.
Definition:
sample-test-suite.cc:116
ns3::tests::SampleTestSuite
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Definition:
sample-test-suite.cc:131
ns3::tests::SampleTestSuite::SampleTestSuite
SampleTestSuite()
Constructor.
Definition:
sample-test-suite.cc:137
ns3::tests::g_sampleTestSuite
static SampleTestSuite g_sampleTestSuite
SampleTestSuite instance variable.
Definition:
sample-test-suite.cc:148
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:144
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:337
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
test
sample-test-suite.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1