A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-channel-condition-model-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
8#include "ns3/abort.h"
9#include "ns3/buildings-channel-condition-model.h"
10#include "ns3/buildings-module.h"
11#include "ns3/config.h"
12#include "ns3/constant-position-mobility-model.h"
13#include "ns3/log.h"
14#include "ns3/simulator.h"
15#include "ns3/test.h"
16
17using namespace ns3;
18
19NS_LOG_COMPONENT_DEFINE("BuildingsChannelConditionModelsTest");
20
21/**
22 * @ingroup building-test
23 *
24 * Test case for the class BuildingsChannelConditionModel. It checks if the
25 * channel condition is correctly determined when a building is deployed in the
26 * scenario
27 */
29{
30 public:
31 /**
32 * Constructor
33 */
35
36 /**
37 * Destructor
38 */
40
41 private:
42 /**
43 * Builds the simulation scenario and perform the tests
44 */
45 void DoRun() override;
46
47 /**
48 * Struct containing the parameters for each test
49 */
51 {
52 Vector m_positionA; //!< the position of the first node
53 Vector m_positionB; //!< the position of the second node
54 ChannelCondition::LosConditionValue m_losCond; //!< the correct channel condition
55 };
56
57 TestVectors<TestVector> m_testVectors; //!< array containing all the test vectors
58};
59
61 : TestCase("Test case for the BuildingsChannelConditionModel"),
63{
64}
65
69
70void
72{
73 TestVector testVector;
74
75 testVector.m_positionA = Vector(0.0, 5.0, 1.5);
76 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
78 m_testVectors.Add(testVector);
79
80 testVector.m_positionA = Vector(0.0, 11.0, 1.5);
81 testVector.m_positionB = Vector(20.0, 11.0, 1.5);
83 m_testVectors.Add(testVector);
84
85 testVector.m_positionA = Vector(5.0, 5.0, 1.5);
86 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
88 m_testVectors.Add(testVector);
89
90 testVector.m_positionA = Vector(4.0, 5.0, 1.5);
91 testVector.m_positionB = Vector(5.0, 5.0, 1.5);
93 m_testVectors.Add(testVector);
94
95 // Deploy nodes and building and get the channel condition
97 nodes.Create(2);
98
100 nodes.Get(0)->AggregateObject(a);
101
103 nodes.Get(1)->AggregateObject(b);
104
106
107 Ptr<Building> building = Create<Building>();
108 building->SetNRoomsX(1);
109 building->SetNRoomsY(1);
110 building->SetNFloors(1);
111 building->SetBoundaries(Box(0.0, 10.0, 0.0, 10.0, 0.0, 5.0));
112 building->SetExtWallsType(Building::ExtWallsType_t::Wood);
113
115
116 for (uint32_t i = 0; i < m_testVectors.GetN(); ++i)
117 {
118 testVector = m_testVectors.Get(i);
119 a->SetPosition(testVector.m_positionA);
120 b->SetPosition(testVector.m_positionB);
121 Ptr<MobilityBuildingInfo> buildingInfoA = a->GetObject<MobilityBuildingInfo>();
122 buildingInfoA->MakeConsistent(a);
123 Ptr<MobilityBuildingInfo> buildingInfoB = b->GetObject<MobilityBuildingInfo>();
124 buildingInfoA->MakeConsistent(b);
125 Ptr<ChannelCondition> cond = condModel->GetChannelCondition(a, b);
126
127 NS_LOG_DEBUG("Got " << cond->GetLosCondition() << " expected condition "
128 << testVector.m_losCond);
129 NS_TEST_ASSERT_MSG_EQ(cond->GetLosCondition(),
130 testVector.m_losCond,
131 " Got unexpected channel condition");
132 }
133
135}
136
137/**
138 * @ingroup building-test
139 * Test suite for the buildings channel condition model
140 */
146
152
153/// Static variable for test initialization
Test case for the class BuildingsChannelConditionModel.
void DoRun() override
Builds the simulation scenario and perform the tests.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
Test suite for the buildings channel condition model.
a 3d box
Definition box.h:24
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
LosConditionValue
Possible values for Line-of-Sight condition.
mobility buildings information (to be used by mobility models)
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
@ QUICK
Fast test.
Definition test.h:1055
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1274
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:490
static constexpr auto UNIT
Definition test.h:1291
A simple way to store test vectors (for stimulus or from responses)
Definition test.h:1348
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ChannelCondition::LosConditionValue m_losCond
the correct channel condition