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