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 * 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
18using namespace ns3;
19
20/**
21 * \ingroup antenna-tests
22 *
23 * \brief IsotropicAntennaModel Test
24 */
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
48std::string
50{
51 std::ostringstream oss;
52 oss << "theta=" << a.GetInclination() << " , phi=" << a.GetAzimuth();
53 return oss.str();
54}
55
57 : TestCase(BuildNameString(a)),
58 m_a(a),
59 m_expectedGain(expectedGainDb)
60{
61}
62
63void
65{
67 double actualGain = a->GetGainDb(m_a);
70 0.01,
71 "wrong value of the radiation pattern");
72}
73
74/**
75 * \ingroup antenna-tests
76 *
77 * \brief IsotropicAntennaModel TestSuite
78 */
84
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);
91 TestCase::Duration::QUICK);
92 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI, 0), 0.0), TestCase::Duration::QUICK);
94 TestCase::Duration::QUICK);
95 AddTestCase(new IsotropicAntennaModelTestCase(Angles(M_PI, M_PI_2), 0.0),
96 TestCase::Duration::QUICK);
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
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:107
double GetInclination() const
Getter for inclination angle.
Definition angles.cc:236
double GetAzimuth() const
Getter for azimuth angle.
Definition angles.cc:230
Smart pointer class similar to boost::intrusive_ptr.
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
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static IsotropicAntennaModelTestSuite g_staticIsotropicAntennaModelTestSuiteInstance
Static variable for test initialization.