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 }
103 
109 {
110 }
111 
116 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 
132 {
133 public:
135  SampleTestSuite ();
136 };
137 
139  : TestSuite ("sample")
140 {
142 }
143 
144 // Do not forget to allocate an instance of this TestSuite
150 
151 
152  } // namespace tests
153 
154 } // namespace ns3
A suite of tests to run.
Definition: test.h:1342
This is an example TestCase.
encapsulates test code
Definition: test.h:1155
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:168
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:380
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...