A Discrete-Event Network Simulator
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
29using namespace ns3;
30
31/**
32 * \ingroup antenna-tests
33 *
34 * \brief IsotropicAntennaModel Test
35 */
37{
38 public:
39 /**
40 * Build the test name
41 * \param a Antenna angle
42 * \return the test name
43 */
44 static std::string BuildNameString(Angles a);
45 /**
46 * Constructor
47 * \param a Antenna angle
48 * \param expectedGainDb Expected antenna gain
49 */
50 IsotropicAntennaModelTestCase(Angles a, double expectedGainDb);
51
52 private:
53 void DoRun() override;
54
55 Angles m_a; //!< Antenna angle
56 double m_expectedGain; //!< Expected gain
57};
58
59std::string
61{
62 std::ostringstream oss;
63 oss << "theta=" << a.GetInclination() << " , phi=" << a.GetAzimuth();
64 return oss.str();
65}
66
68 : TestCase(BuildNameString(a)),
69 m_a(a),
70 m_expectedGain(expectedGainDb)
71{
72}
73
74void
76{
77 Ptr<IsotropicAntennaModel> a = CreateObject<IsotropicAntennaModel>();
78 double actualGain = a->GetGainDb(m_a);
81 0.01,
82 "wrong value of the radiation pattern");
83}
84
85/**
86 * \ingroup antenna-tests
87 *
88 * \brief IsotropicAntennaModel TestSuite
89 */
91{
92 public:
94};
95
97 : TestSuite("isotropic-antenna-model", Type::UNIT)
98{
99 AddTestCase(new IsotropicAntennaModelTestCase(Angles(0, 0), 0.0), TestCase::Duration::QUICK);
100 AddTestCase(new IsotropicAntennaModelTestCase(Angles(0, M_PI), 0.0), TestCase::Duration::QUICK);
102 TestCase::Duration::QUICK);
103 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI, 0), 0.0), TestCase::Duration::QUICK);
105 TestCase::Duration::QUICK);
106 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI, M_PI_2), 0.0),
107 TestCase::Duration::QUICK);
109 TestCase::Duration::QUICK);
110 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI_2, M_PI), 0.0),
111 TestCase::Duration::QUICK);
112 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI_2, M_PI_2), 0.0),
113 TestCase::Duration::QUICK);
114}
115
116/// Static variable for test initialization
IsotropicAntennaModel Test.
IsotropicAntennaModelTestCase(Angles a, double expectedGainDb)
Constructor.
static std::string BuildNameString(Angles a)
Build the test name.
void DoRun() override
Implementation to actually run this TestCase.
IsotropicAntennaModel TestSuite.
Class holding the azimuth and inclination angles of spherical coordinates.
Definition: angles.h:118
double GetInclination() const
Getter for inclination angle.
Definition: angles.cc:246
double GetAzimuth() const
Getter for azimuth angle.
Definition: angles.cc:240
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
#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:511
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static IsotropicAntennaModelTestSuite g_staticIsotropicAntennaModelTestSuiteInstance
Static variable for test initialization.