A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
qkd-test-suite.cc
Go to the documentation of this file.
1
2
// Include a header file from your module to test.
3
#include "ns3/qkd.h"
4
5
// An essential include is test.h
6
#include "ns3/test.h"
7
8
// Do not put your test classes in namespace ns3. You may find it useful
9
// to use the using directive to access the ns3 namespace directly
10
using namespace
ns3
;
11
12
// This is an example TestCase.
13
class
QkdTestCase1
:
public
TestCase
14
{
15
public
:
16
QkdTestCase1
();
17
~QkdTestCase1
();
18
19
private
:
20
virtual
void
DoRun
();
21
};
22
23
// Add some help text to this case to describe what it is intended to test
24
QkdTestCase1::QkdTestCase1
()
25
:
TestCase
(
"Qkd test case(does nothing)"
)
26
{
27
}
28
29
// This destructor does nothing but we include it as a reminder that
30
// the test case should clean up after itself
31
QkdTestCase1::~QkdTestCase1
()
32
{
33
}
34
35
//
36
// This method is the pure virtual method from class TestCase that every
37
// TestCase must implement
38
//
39
void
40
QkdTestCase1::DoRun
()
41
{
42
// A wide variety of test macros are available in src/core/test.h
43
NS_TEST_ASSERT_MSG_EQ
(
true
,
true
,
"true doesn't equal true for some reason"
);
44
// Use this one for floating point comparisons
45
NS_TEST_ASSERT_MSG_EQ_TOL
(0.01, 0.01, 0.001,
"Numbers are not equal within tolerance"
);
46
}
47
48
// The TestSuite class names the TestSuite, identifies what type of TestSuite,
49
// and enables the TestCases to be run. Typically, only the constructor for
50
// this class must be defined
51
//
52
class
QkdTestSuite
:
public
TestSuite
53
{
54
public
:
55
QkdTestSuite
();
56
};
57
58
QkdTestSuite::QkdTestSuite
()
59
:
TestSuite
(
"qkd"
, UNIT)
60
{
61
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
62
AddTestCase
(
new
QkdTestCase1
,
TestCase::QUICK
);
63
}
64
65
// Do not forget to allocate an instance of this TestSuite
66
static
QkdTestSuite
qkdTestSuite
;
67
QkdTestCase1
Definition
qkd-test-suite.cc:14
QkdTestCase1::~QkdTestCase1
~QkdTestCase1()
Definition
qkd-test-suite.cc:31
QkdTestCase1::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition
qkd-test-suite.cc:40
QkdTestCase1::QkdTestCase1
QkdTestCase1()
Definition
qkd-test-suite.cc:24
QkdTestSuite
Definition
qkd-test-suite.cc:53
QkdTestSuite::QkdTestSuite
QkdTestSuite()
Definition
qkd-test-suite.cc:58
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::QUICK
static constexpr auto QUICK
Deprecated test duration simple enums.
Definition
test.h:1067
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
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:134
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:327
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
qkdTestSuite
static QkdTestSuite qkdTestSuite
Definition
qkd-test-suite.cc:66
src
qkd
test
qkd-test-suite.cc
Generated on Mon Dec 15 2025 15:22:03 for ns-3 by
1.9.8