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
);
60
}
61
62
// Do not forget to allocate an instance of this TestSuite
63
static
SampleTestSuite
sampleTestSuite
;
src
core
test
sample-test-suite.cc
Generated on Fri Dec 21 2012 19:00:33 for ns-3 by
1.8.1.2