A Discrete-Event Network Simulator
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:
91  ~SampleTestCase1() override;
92 
93  private:
94  void DoRun() override;
95 };
96 
99  : TestCase("Sample test case (does nothing)")
100 {
101 }
102 
108 {
109 }
110 
115 void
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 
131 {
132  public:
134  SampleTestSuite();
135 };
136 
138  : TestSuite("sample")
139 {
141 }
142 
143 // Do not forget to allocate an instance of this TestSuite
149 
150 } // namespace tests
151 
152 } // namespace ns3
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
This is an example TestCase.
~SampleTestCase1() override
Destructor.
void DoRun() override
This method is the pure virtual method from class TestCase that every TestCase must implement.
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
static SampleTestSuite g_sampleTestSuite
SampleTestSuite instance variable.
#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
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.