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));
81
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI), 0.0));
82
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(0, M_PI_2), 0.0));
83
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, 0), 0.0));
84
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI), 0.0));
85
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI, M_PI_2), 0.0));
86
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, 0), 0.0));
87
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI), 0.0));
88
AddTestCase
(
new
IsotropicAntennaModelTestCase
(
Angles
(M_PI_2, M_PI_2), 0.0));
89
90
};
91
92
static
IsotropicAntennaModelTestSuite
staticIsotropicAntennaModelTestSuiteInstance
;
93
94
95
96
97
}
// namespace ns3
src
antenna
test
test-isotropic-antenna.cc
Generated on Tue Oct 9 2012 16:45:32 for ns-3 by
1.8.1.2