A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
core
test
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
}
103
108
SampleTestCase1::~SampleTestCase1
()
109
{
110
}
111
116
void
117
SampleTestCase1::DoRun
(
void
)
118
{
119
// A wide variety of test macros are available in src/core/test.h
120
NS_TEST_ASSERT_MSG_EQ
(
true
,
true
,
"true doesn't equal true for some reason"
);
121
// Use this one for floating point comparisons
122
NS_TEST_ASSERT_MSG_EQ_TOL
(0.01, 0.01, 0.001,
"Numbers are not equal within tolerance"
);
123
}
124
131
class
SampleTestSuite
:
public
TestSuite
132
{
133
public
:
135
SampleTestSuite
();
136
};
137
138
SampleTestSuite::SampleTestSuite
()
139
:
TestSuite
(
"sample"
)
140
{
141
AddTestCase
(
new
SampleTestCase1
);
142
}
143
144
// Do not forget to allocate an instance of this TestSuite
149
static
SampleTestSuite
g_sampleTestSuite
;
150
151
152
}
// namespace tests
153
154
}
// namespace ns3
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1342
ns3::tests::SampleTestCase1
This is an example TestCase.
Definition:
sample-test-suite.cc:86
ns3::TestCase
encapsulates test code
Definition:
test.h:1155
ns3::tests::SampleTestSuite::SampleTestSuite
SampleTestSuite()
Constructor.
Definition:
sample-test-suite.cc:138
ns3::tests::SampleTestCase1::SampleTestCase1
SampleTestCase1()
Constructor.
Definition:
sample-test-suite.cc:99
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
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:168
ns3::tests::g_sampleTestSuite
static SampleTestSuite g_sampleTestSuite
SampleTestSuite instance variable.
Definition:
sample-test-suite.cc:149
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:380
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::tests::SampleTestCase1::~SampleTestCase1
virtual ~SampleTestCase1()
Destructor.
Definition:
sample-test-suite.cc:108
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:117
Generated on Wed Nov 7 2018 10:01:51 for ns-3 by
1.8.14