A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
test-isotropic-antenna.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 CTTC
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
#include <ns3/log.h>
22
#include <ns3/test.h>
23
#include <ns3/isotropic-antenna-model.h>
24
#include <cmath>
25
#include <string>
26
#include <iostream>
27
#include <sstream>
28
29
namespace
ns3 {
30
31
class
IsotropicAntennaModelTestCase
:
public
TestCase
32
{
33
public
:
34
static
std::string
BuildNameString
(
Angles
a);
35
IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb);
36
37
38
private
:
39
virtual
void
DoRun
(
void
);
40
41
Angles
m_a
;
42
double
m_expectedGain
;
43
};
44
45
std::string
IsotropicAntennaModelTestCase::BuildNameString
(
Angles
a)
46
{
47
std::ostringstream oss;
48
oss <<
"theta="
<< a.
theta
<<
" , phi="
<< a.
phi
;
49
return
oss.str ();
50
}
51
52
53
IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
(
Angles
a,
double
expectedGainDb)
54
:
TestCase
(BuildNameString (a)),
55
m_a (a),
56
m_expectedGain (expectedGainDb)
57
{
58
}
59
60
void
61
IsotropicAntennaModelTestCase::DoRun
()
62
{
63
Ptr<IsotropicAntennaModel>
a = Create<IsotropicAntennaModel> ();
64
double
actualGain = a->GetGainDb (
m_a
);
65
NS_TEST_EXPECT_MSG_EQ_TOL
(actualGain,
m_expectedGain
, 0.01,
"wrong value of the radiation pattern"
);
66
}
67
68
69
70
71
class
IsotropicAntennaModelTestSuite
:
public
TestSuite
72
{
73
public
:
74
IsotropicAntennaModelTestSuite
();
75
};
76
77
IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
()
78
:
TestSuite
(
"isotropic-antenna-model"
, UNIT)
79
{
80
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, 0), 0.0),
TestCase::QUICK
);
81
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI), 0.0),
TestCase::QUICK
);
82
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI_2), 0.0),
TestCase::QUICK
);
83
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, 0), 0.0),
TestCase::QUICK
);
84
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI), 0.0),
TestCase::QUICK
);
85
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI_2), 0.0),
TestCase::QUICK
);
86
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, 0), 0.0),
TestCase::QUICK
);
87
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI), 0.0),
TestCase::QUICK
);
88
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI_2), 0.0),
TestCase::QUICK
);
89
90
};
91
92
static
IsotropicAntennaModelTestSuite
staticIsotropicAntennaModelTestSuiteInstance
;
93
94
95
96
97
}
// namespace ns3
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
ns3::IsotropicAntennaModelTestCase::IsotropicAntennaModelTestCase
IsotropicAntennaModelTestCase(Angles a, double expectedGainDb)
Definition:
test-isotropic-antenna.cc:53
ns3::IsotropicAntennaModelTestSuite
Definition:
test-isotropic-antenna.cc:71
ns3::IsotropicAntennaModelTestCase::m_expectedGain
double m_expectedGain
Definition:
test-isotropic-antenna.cc:42
ns3::Angles::theta
double theta
the inclination angle in radians
Definition:
angles.h:117
ns3::TestCase
encapsulates test code
Definition:
test.h:849
ns3::IsotropicAntennaModelTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
test-isotropic-antenna.cc:61
ns3::IsotropicAntennaModelTestCase::BuildNameString
static std::string BuildNameString(Angles a)
Definition:
test-isotropic-antenna.cc:45
ns3::IsotropicAntennaModelTestSuite::IsotropicAntennaModelTestSuite
IsotropicAntennaModelTestSuite()
Definition:
test-isotropic-antenna.cc:77
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:485
ns3::staticIsotropicAntennaModelTestSuiteInstance
static IsotropicAntennaModelTestSuite staticIsotropicAntennaModelTestSuiteInstance
Definition:
test-isotropic-antenna.cc:90
ns3::IsotropicAntennaModelTestCase::m_a
Angles m_a
Definition:
test-isotropic-antenna.cc:41
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:173
ns3::IsotropicAntennaModelTestCase
Definition:
test-isotropic-antenna.cc:31
ns3::TestCase::QUICK
Fast test.
Definition:
test.h:857
ns3::Angles::phi
double phi
the azimuth angle in radians
Definition:
angles.h:111
ns3::Angles
struct holding the azimuth and inclination angles of spherical coordinates.
Definition:
angles.h:71
src
antenna
test
test-isotropic-antenna.cc
Generated on Sat Apr 19 2014 14:06:49 for ns-3 by
1.8.6