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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Nicola Baldo <nbaldo@cttc.es>
7
*/
8
9
#include <ns3/isotropic-antenna-model.h>
10
#include <ns3/log.h>
11
#include <ns3/test.h>
12
13
#include <cmath>
14
#include <iostream>
15
#include <sstream>
16
#include <string>
17
18
using namespace
ns3
;
19
20
/**
21
* @ingroup antenna-tests
22
*
23
* @brief IsotropicAntennaModel Test
24
*/
25
class
IsotropicAntennaModelTestCase
:
public
TestCase
26
{
27
public
:
28
/**
29
* Build the test name
30
* @param a Antenna angle
31
* @return the test name
32
*/
33
static
std::string
BuildNameString
(
Angles
a);
34
/**
35
* Constructor
36
* @param a Antenna angle
37
* @param expectedGainDb Expected antenna gain
38
*/
39
IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb);
40
41
private
:
42
void
DoRun
()
override
;
43
44
Angles
m_a
;
//!< Antenna angle
45
double
m_expectedGain
;
//!< Expected gain
46
};
47
48
std::string
49
IsotropicAntennaModelTestCase::BuildNameString
(
Angles
a)
50
{
51
std::ostringstream oss;
52
oss <<
"theta="
<< a.
GetInclination
() <<
" , phi="
<< a.
GetAzimuth
();
53
return
oss.str();
54
}
55
56
IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb)
57
:
TestCase
(BuildNameString(a)),
58
m_a(a),
59
m_expectedGain(expectedGainDb)
60
{
61
}
62
63
void
64
IsotropicAntennaModelTestCase::DoRun
()
65
{
66
Ptr<IsotropicAntennaModel>
a =
CreateObject<IsotropicAntennaModel>
();
67
double
actualGain = a->GetGainDb(
m_a
);
68
NS_TEST_EXPECT_MSG_EQ_TOL
(actualGain,
69
m_expectedGain
,
70
0.01,
71
"wrong value of the radiation pattern"
);
72
}
73
74
/**
75
* @ingroup antenna-tests
76
*
77
* @brief IsotropicAntennaModel TestSuite
78
*/
79
class
IsotropicAntennaModelTestSuite
:
public
TestSuite
80
{
81
public
:
82
IsotropicAntennaModelTestSuite
();
83
};
84
85
IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
()
86
:
TestSuite
(
"isotropic-antenna-model"
,
Type
::UNIT)
87
{
88
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, 0), 0.0), TestCase::Duration::QUICK);
89
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI), 0.0), TestCase::Duration::QUICK);
90
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI_2), 0.0),
91
TestCase::Duration::QUICK);
92
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, 0), 0.0), TestCase::Duration::QUICK);
93
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI), 0.0),
94
TestCase::Duration::QUICK);
95
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI_2), 0.0),
96
TestCase::Duration::QUICK);
97
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, 0), 0.0),
98
TestCase::Duration::QUICK);
99
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI), 0.0),
100
TestCase::Duration::QUICK);
101
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI_2), 0.0),
102
TestCase::Duration::QUICK);
103
}
104
105
/// Static variable for test initialization
106
static
IsotropicAntennaModelTestSuite
g_staticIsotropicAntennaModelTestSuiteInstance
;
IsotropicAntennaModelTestCase
IsotropicAntennaModel Test.
Definition
test-isotropic-antenna.cc:26
IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
IsotropicAntennaModelTestCase(Angles a, double expectedGainDb)
Constructor.
Definition
test-isotropic-antenna.cc:56
IsotropicAntennaModelTestCase::m_expectedGain
double m_expectedGain
Expected gain.
Definition
test-isotropic-antenna.cc:45
IsotropicAntennaModelTestCase::BuildNameString
static std::string BuildNameString(Angles a)
Build the test name.
Definition
test-isotropic-antenna.cc:49
IsotropicAntennaModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
test-isotropic-antenna.cc:64
IsotropicAntennaModelTestCase::m_a
Angles m_a
Antenna angle.
Definition
test-isotropic-antenna.cc:44
IsotropicAntennaModelTestSuite
IsotropicAntennaModel TestSuite.
Definition
test-isotropic-antenna.cc:80
IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
IsotropicAntennaModelTestSuite()
Definition
test-isotropic-antenna.cc:85
ns3::Angles
Class holding the azimuth and inclination angles of spherical coordinates.
Definition
angles.h:107
ns3::Angles::GetInclination
double GetInclination() const
Getter for inclination angle.
Definition
angles.cc:236
ns3::Angles::GetAzimuth
double GetAzimuth() const
Getter for azimuth angle.
Definition
angles.cc:230
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
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:500
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:106
src
antenna
test
test-isotropic-antenna.cc
Generated on Fri Dec 13 2024 09:20:37 for ns-3 by
1.11.0