A Discrete-Event Network Simulator
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 
100  : TestCase ("Sample test case (does nothing)")
101 {}
102 
108 {}
109 
114 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 
130 {
131 public:
133  SampleTestSuite ();
134 };
135 
137  : TestSuite ("sample")
138 {
140 }
141 
142 // Do not forget to allocate an instance of this TestSuite
148 
149 
150 } // namespace tests
151 
152 } // namespace ns3
A suite of tests to run.
Definition: test.h:1343
This is an example TestCase.
encapsulates test code
Definition: test.h:1153
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
#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:166
static SampleTestSuite g_sampleTestSuite
SampleTestSuite instance variable.
#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:378
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual ~SampleTestCase1()
Destructor.
virtual void DoRun(void)
This method is the pure virtual method from class TestCase that every TestCase must implement...