A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
sample-test-suite.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
3
// An essential include is test.h
4
#include "ns3/test.h"
5
6
// Do not put your test classes in namespace ns3. You may find it useful
7
// to use the using directive to access the ns3 namespace directly
8
using namespace
ns3;
9
10
// This is an example TestCase.
11
class
SampleTestCase1
:
public
TestCase
12
{
13
public
:
14
SampleTestCase1
();
15
virtual
~
SampleTestCase1
();
16
17
private
:
18
virtual
void
DoRun (
void
);
19
};
20
21
// Add some help text to this case to describe what it is intended to test
22
SampleTestCase1::SampleTestCase1
()
23
:
TestCase
(
"Sample test case (does nothing)"
)
24
{
25
}
26
27
// This destructor does nothing but we include it as a reminder that
28
// the test case should clean up after itself
29
SampleTestCase1::~SampleTestCase1
()
30
{
31
}
32
33
//
34
// This method is the pure virtual method from class TestCase that every
35
// TestCase must implement
36
//
37
void
38
SampleTestCase1::DoRun
(
void
)
39
{
40
// A wide variety of test macros are available in src/core/test.h
41
NS_TEST_ASSERT_MSG_EQ
(
true
,
true
,
"true doesn't equal true for some reason"
);
42
// Use this one for floating point comparisons
43
NS_TEST_ASSERT_MSG_EQ_TOL
(0.01, 0.01, 0.001,
"Numbers are not equal within tolerance"
);
44
}
45
46
// The TestSuite class names the TestSuite, identifies what type of TestSuite,
47
// and enables the TestCases to be run. Typically, only the constructor for
48
// this class must be defined
49
//
50
class
SampleTestSuite
:
public
TestSuite
51
{
52
public
:
53
SampleTestSuite
();
54
};
55
56
SampleTestSuite::SampleTestSuite
()
57
:
TestSuite
(
"sample"
, UNIT)
58
{
59
AddTestCase
(
new
SampleTestCase1
, TestCase::QUICK);
60
}
61
62
// Do not forget to allocate an instance of this TestSuite
63
static
SampleTestSuite
sampleTestSuite
;
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:326
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
SampleTestCase1::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
sample-test-suite.cc:38
ns3::TestCase
encapsulates test code
Definition:
test.h:849
sampleTestSuite
static SampleTestSuite sampleTestSuite
Definition:
sample-test-suite.cc:63
SampleTestCase1::~SampleTestCase1
virtual ~SampleTestCase1()
Definition:
sample-test-suite.cc:29
SampleTestSuite
Definition:
sample-test-suite.cc:50
SampleTestCase1::SampleTestCase1
SampleTestCase1()
Definition:
sample-test-suite.cc:22
SampleTestCase1
Definition:
sample-test-suite.cc:11
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:173
SampleTestSuite::SampleTestSuite
SampleTestSuite()
Definition:
sample-test-suite.cc:56
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:137
src
core
test
sample-test-suite.cc
Generated on Sat Apr 19 2014 14:06:53 for ns-3 by
1.8.6