A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
test-isotropic-antenna.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
18
*/
19
20
#include <ns3/isotropic-antenna-model.h>
21
#include <ns3/log.h>
22
#include <ns3/test.h>
23
24
#include <cmath>
25
#include <iostream>
26
#include <sstream>
27
#include <string>
28
29
using namespace
ns3
;
30
36
class
IsotropicAntennaModelTestCase
:
public
TestCase
37
{
38
public
:
44
static
std::string
BuildNameString
(
Angles
a);
50
IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb);
51
52
private
:
53
void
DoRun
()
override
;
54
55
Angles
m_a
;
56
double
m_expectedGain
;
57
};
58
59
std::string
60
IsotropicAntennaModelTestCase::BuildNameString
(
Angles
a)
61
{
62
std::ostringstream oss;
63
oss <<
"theta="
<< a.
GetInclination
() <<
" , phi="
<< a.
GetAzimuth
();
64
return
oss.str();
65
}
66
67
IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb)
68
:
TestCase
(BuildNameString(a)),
69
m_a(a),
70
m_expectedGain(expectedGainDb)
71
{
72
}
73
74
void
75
IsotropicAntennaModelTestCase::DoRun
()
76
{
77
Ptr<IsotropicAntennaModel>
a = CreateObject<IsotropicAntennaModel>();
78
double
actualGain = a->GetGainDb(
m_a
);
79
NS_TEST_EXPECT_MSG_EQ_TOL
(actualGain,
80
m_expectedGain
,
81
0.01,
82
"wrong value of the radiation pattern"
);
83
}
84
90
class
IsotropicAntennaModelTestSuite
:
public
TestSuite
91
{
92
public
:
93
IsotropicAntennaModelTestSuite
();
94
};
95
96
IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
()
97
:
TestSuite
(
"isotropic-antenna-model"
, UNIT)
98
{
99
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, 0), 0.0),
TestCase::QUICK
);
100
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI), 0.0),
TestCase::QUICK
);
101
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI_2), 0.0),
TestCase::QUICK
);
102
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, 0), 0.0),
TestCase::QUICK
);
103
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI), 0.0),
TestCase::QUICK
);
104
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI_2), 0.0),
TestCase::QUICK
);
105
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, 0), 0.0),
TestCase::QUICK
);
106
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI), 0.0),
TestCase::QUICK
);
107
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI_2), 0.0),
TestCase::QUICK
);
108
}
109
111
static
IsotropicAntennaModelTestSuite
g_staticIsotropicAntennaModelTestSuiteInstance
;
IsotropicAntennaModelTestCase
IsotropicAntennaModel Test.
Definition:
test-isotropic-antenna.cc:37
IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
IsotropicAntennaModelTestCase(Angles a, double expectedGainDb)
Constructor.
Definition:
test-isotropic-antenna.cc:67
IsotropicAntennaModelTestCase::m_expectedGain
double m_expectedGain
Expected gain.
Definition:
test-isotropic-antenna.cc:56
IsotropicAntennaModelTestCase::BuildNameString
static std::string BuildNameString(Angles a)
Build the test name.
Definition:
test-isotropic-antenna.cc:60
IsotropicAntennaModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
test-isotropic-antenna.cc:75
IsotropicAntennaModelTestCase::m_a
Angles m_a
Antenna angle.
Definition:
test-isotropic-antenna.cc:55
IsotropicAntennaModelTestSuite
IsotropicAntennaModel TestSuite.
Definition:
test-isotropic-antenna.cc:91
IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
IsotropicAntennaModelTestSuite()
Definition:
test-isotropic-antenna.cc:96
ns3::Angles
Class holding the azimuth and inclination angles of spherical coordinates.
Definition:
angles.h:118
ns3::Angles::GetInclination
double GetInclination() const
Getter for inclination angle.
Definition:
angles.cc:246
ns3::Angles::GetAzimuth
double GetAzimuth() const
Getter for azimuth angle.
Definition:
angles.cc:240
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::QUICK
@ QUICK
Fast test.
Definition:
test.h:1065
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_TOL
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Definition:
test.h:510
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
g_staticIsotropicAntennaModelTestSuiteInstance
static IsotropicAntennaModelTestSuite g_staticIsotropicAntennaModelTestSuiteInstance
Static variable for test initialization.
Definition:
test-isotropic-antenna.cc:111
src
antenna
test
test-isotropic-antenna.cc
Generated on Thu Feb 8 2024 09:24:01 for ns-3 by
1.9.6