A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
rocketfuel-topology-reader-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Hajime Tazaki
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
7 */
8
9//-----------------------------------------------------------------------------
10// Unit tests
11//-----------------------------------------------------------------------------
12
13#include "ns3/abort.h"
14#include "ns3/attribute.h"
15#include "ns3/log.h"
16#include "ns3/node-container.h"
17#include "ns3/object-factory.h"
18#include "ns3/rocketfuel-topology-reader.h"
19#include "ns3/simulator.h"
20#include "ns3/test.h"
21
22using namespace ns3;
23
24/**
25 * @defgroup topology-test Topology module tests
26 * @ingroup topology
27 * @ingroup tests
28 */
29
30/**
31 * @file
32 * @ingroup topology-test
33 * ns3::RockefuelTopologyReader test suite.
34 */
35
36/**
37 * @ingroup topology-test
38
39 * @brief Rocketfuel Topology Reader Weights Test
40 */
42{
43 public:
45
46 private:
47 void DoRun() override;
48};
49
51 : TestCase("RocketfuelTopologyReaderWeightsTest")
52{
53}
54
55void
57{
60
61 std::string input("./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt");
62
64 inFile->SetFileName(input);
65
66 if (inFile)
67 {
68 nodes = inFile->Read();
69 }
70
71 NS_TEST_ASSERT_MSG_NE(nodes.GetN(), 0, "Problems reading node information the topology file..");
72
73 NS_TEST_ASSERT_MSG_NE(inFile->LinksSize(), 0, "Problems reading the topology file.");
74
75 NS_TEST_EXPECT_MSG_EQ(nodes.GetN(), 315, "nodes");
76 NS_TEST_EXPECT_MSG_EQ(inFile->LinksSize(), 972, "links");
78}
79
80/**
81 * @ingroup topology-test
82 * @brief Rocketfuel Topology Reader Maps Test
83 */
85{
86 public:
88
89 private:
90 void DoRun() override;
91};
92
94 : TestCase("RocketfuelTopologyReaderMapsTest")
95{
96}
97
98void
100{
103
104 std::string input("./src/topology-read/examples/RocketFuel_sample_4755.r0.cch_maps.txt");
105
107 inFile->SetFileName(input);
108
109 if (inFile)
110 {
111 nodes = inFile->Read();
112 }
113
114 NS_TEST_ASSERT_MSG_NE(nodes.GetN(), 0, "Problems reading node information the topology file..");
115
116 NS_TEST_ASSERT_MSG_NE(inFile->LinksSize(), 0, "Problems reading the topology file.");
117
118 NS_TEST_EXPECT_MSG_EQ(nodes.GetN(), 12, "nodes");
119 NS_TEST_EXPECT_MSG_EQ(inFile->LinksSize(), 24, "links");
121}
122
123/**
124 * @ingroup topology-test
125 *
126 * @brief Rocketfuel Topology Reader TestSuite
127 */
129{
130 public:
132
133 private:
134};
135
137 : TestSuite("rocketfuel-topology-reader", Type::UNIT)
138{
139 AddTestCase(new RocketfuelTopologyReaderWeightsTest(), TestCase::Duration::QUICK);
140 AddTestCase(new RocketfuelTopologyReaderMapsTest(), TestCase::Duration::QUICK);
141}
142
143/**
144 * @ingroup topology-test
145 * Static variable for test initialization
146 */
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:241
#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:554
static RocketfuelTopologyReaderTestSuite g_rocketfuelTopologyReaderTestSuite
Static variable for test initialization.
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.