A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
rocketfuel-topology-reader-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Hajime Tazaki
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
18
*/
19
20
//-----------------------------------------------------------------------------
21
// Unit tests
22
//-----------------------------------------------------------------------------
23
24
#include "ns3/abort.h"
25
#include "ns3/attribute.h"
26
#include "ns3/log.h"
27
#include "ns3/node-container.h"
28
#include "ns3/object-factory.h"
29
#include "ns3/rocketfuel-topology-reader.h"
30
#include "ns3/simulator.h"
31
#include "ns3/test.h"
32
33
using namespace
ns3
;
34
52
class
RocketfuelTopologyReaderWeightsTest
:
public
TestCase
53
{
54
public
:
55
RocketfuelTopologyReaderWeightsTest
();
56
57
private
:
58
void
DoRun()
override
;
59
};
60
61
RocketfuelTopologyReaderWeightsTest::RocketfuelTopologyReaderWeightsTest
()
62
:
TestCase
(
"RocketfuelTopologyReaderWeightsTest"
)
63
{
64
}
65
66
void
67
RocketfuelTopologyReaderWeightsTest::DoRun
()
68
{
69
Ptr<RocketfuelTopologyReader>
inFile;
70
NodeContainer
nodes
;
71
72
std::string input(
"./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt"
);
73
74
inFile = CreateObject<RocketfuelTopologyReader>();
75
inFile->SetFileName(input);
76
77
if
(inFile)
78
{
79
nodes
= inFile->Read();
80
}
81
82
NS_TEST_ASSERT_MSG_NE
(
nodes
.
GetN
(), 0,
"Problems reading node information the topology file.."
);
83
84
NS_TEST_ASSERT_MSG_NE
(inFile->LinksSize(), 0,
"Problems reading the topology file."
);
85
86
NS_TEST_EXPECT_MSG_EQ
(
nodes
.
GetN
(), 315,
"nodes"
);
87
NS_TEST_EXPECT_MSG_EQ
(inFile->LinksSize(), 972,
"links"
);
88
Simulator::Destroy();
89
}
90
95
class
RocketfuelTopologyReaderMapsTest
:
public
TestCase
96
{
97
public
:
98
RocketfuelTopologyReaderMapsTest
();
99
100
private
:
101
void
DoRun
()
override
;
102
};
103
104
RocketfuelTopologyReaderMapsTest::RocketfuelTopologyReaderMapsTest
()
105
:
TestCase
(
"RocketfuelTopologyReaderMapsTest"
)
106
{
107
}
108
109
void
110
RocketfuelTopologyReaderMapsTest::DoRun
()
111
{
112
Ptr<RocketfuelTopologyReader>
inFile;
113
NodeContainer
nodes
;
114
115
std::string input(
"./src/topology-read/examples/RocketFuel_sample_4755.r0.cch_maps.txt"
);
116
117
inFile = CreateObject<RocketfuelTopologyReader>();
118
inFile->SetFileName(input);
119
120
if
(inFile)
121
{
122
nodes
= inFile->Read();
123
}
124
125
NS_TEST_ASSERT_MSG_NE
(
nodes
.
GetN
(), 0,
"Problems reading node information the topology file.."
);
126
127
NS_TEST_ASSERT_MSG_NE
(inFile->LinksSize(), 0,
"Problems reading the topology file."
);
128
129
NS_TEST_EXPECT_MSG_EQ
(
nodes
.
GetN
(), 12,
"nodes"
);
130
NS_TEST_EXPECT_MSG_EQ
(inFile->LinksSize(), 24,
"links"
);
131
Simulator::Destroy();
132
}
133
139
class
RocketfuelTopologyReaderTestSuite
:
public
TestSuite
140
{
141
public
:
142
RocketfuelTopologyReaderTestSuite
();
143
144
private
:
145
};
146
147
RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite
()
148
:
TestSuite
(
"rocketfuel-topology-reader"
, UNIT)
149
{
150
AddTestCase
(
new
RocketfuelTopologyReaderWeightsTest
(), TestCase::QUICK);
151
AddTestCase
(
new
RocketfuelTopologyReaderMapsTest
(), TestCase::QUICK);
152
}
153
158
static
RocketfuelTopologyReaderTestSuite
g_rocketfuelTopologyReaderTestSuite
;
RocketfuelTopologyReaderMapsTest
Rocketfuel Topology Reader Maps Test.
Definition:
rocketfuel-topology-reader-test-suite.cc:96
RocketfuelTopologyReaderMapsTest::RocketfuelTopologyReaderMapsTest
RocketfuelTopologyReaderMapsTest()
Definition:
rocketfuel-topology-reader-test-suite.cc:104
RocketfuelTopologyReaderMapsTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
rocketfuel-topology-reader-test-suite.cc:110
RocketfuelTopologyReaderTestSuite
Rocketfuel Topology Reader TestSuite.
Definition:
rocketfuel-topology-reader-test-suite.cc:140
RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite
RocketfuelTopologyReaderTestSuite()
Definition:
rocketfuel-topology-reader-test-suite.cc:147
RocketfuelTopologyReaderWeightsTest
Rocketfuel Topology Reader Weights Test.
Definition:
rocketfuel-topology-reader-test-suite.cc:53
RocketfuelTopologyReaderWeightsTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
rocketfuel-topology-reader-test-suite.cc:67
RocketfuelTopologyReaderWeightsTest::RocketfuelTopologyReaderWeightsTest
RocketfuelTopologyReaderWeightsTest()
Definition:
rocketfuel-topology-reader-test-suite.cc:61
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Definition:
node-container.cc:72
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
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_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition:
test.h:251
NS_TEST_ASSERT_MSG_NE
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition:
test.h:564
g_rocketfuelTopologyReaderTestSuite
static RocketfuelTopologyReaderTestSuite g_rocketfuelTopologyReaderTestSuite
Static variable for test initialization.
Definition:
rocketfuel-topology-reader-test-suite.cc:158
nodes
NodeContainer nodes
Definition:
lr-wpan-bootstrap.cc:53
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
topology-read
test
rocketfuel-topology-reader-test-suite.cc
Generated on Sun Mar 3 2024 17:11:09 for ns-3 by
1.9.1