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"),
62 m_testVectors()
63{
64}
65
69
70void
72{
74
75 testVector.m_positionA = Vector(0.0, 5.0, 1.5);
76 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
77 testVector.m_losCond = ChannelCondition::LosConditionValue::NLOS;
79
80 testVector.m_positionA = Vector(0.0, 11.0, 1.5);
81 testVector.m_positionB = Vector(20.0, 11.0, 1.5);
82 testVector.m_losCond = ChannelCondition::LosConditionValue::LOS;
84
85 testVector.m_positionA = Vector(5.0, 5.0, 1.5);
86 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
87 testVector.m_losCond = ChannelCondition::LosConditionValue::NLOS;
89
90 testVector.m_positionA = Vector(4.0, 5.0, 1.5);
91 testVector.m_positionB = Vector(5.0, 5.0, 1.5);
92 testVector.m_losCond = ChannelCondition::LosConditionValue::LOS;
94
95 // Deploy nodes and building and get the channel condition
97 nodes.Create(2);
98
101
104
106
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 {
119 a->SetPosition(testVector.m_positionA);
120 b->SetPosition(testVector.m_positionB);
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
148 : TestSuite("buildings-channel-condition-model", Type::UNIT)
149{
150 AddTestCase(new BuildingsChannelConditionModelTestCase, TestCase::Duration::QUICK);
151}
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)
void MakeConsistent(Ptr< MobilityModel > mm)
Make the given mobility model consistent, by determining whether its position falls inside any of the...
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition object.cc:298
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
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
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 > 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