OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 CTTC | 3 * Copyright (c) 2011 CTTC |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Nicola Baldo <nbaldo@cttc.es> | 18 * Author: Nicola Baldo <nbaldo@cttc.es> |
19 */ | 19 */ |
20 | 20 |
21 #include <ns3/log.h> | 21 #include <ns3/log.h> |
22 #include <ns3/test.h> | 22 #include <ns3/test.h> |
23 #include <ns3/isotropic-antenna-model.h> | 23 #include <ns3/isotropic-antenna-model.h> |
| 24 #include <ns3/mobility-module.h> |
24 #include <cmath> | 25 #include <cmath> |
25 #include <string> | 26 #include <string> |
26 #include <iostream> | 27 #include <iostream> |
27 #include <sstream> | 28 #include <sstream> |
28 | 29 |
29 namespace ns3 { | 30 namespace ns3 { |
30 | 31 |
31 class IsotropicAntennaModelTestCase : public TestCase | 32 class IsotropicAntennaModelTestCase : public TestCase |
32 { | 33 { |
33 public: | 34 public: |
(...skipping 20 matching lines...) Expand all Loading... |
54 : TestCase (BuildNameString (a)), | 55 : TestCase (BuildNameString (a)), |
55 m_a (a), | 56 m_a (a), |
56 m_expectedGain (expectedGainDb) | 57 m_expectedGain (expectedGainDb) |
57 { | 58 { |
58 } | 59 } |
59 | 60 |
60 void | 61 void |
61 IsotropicAntennaModelTestCase::DoRun () | 62 IsotropicAntennaModelTestCase::DoRun () |
62 { | 63 { |
63 Ptr<IsotropicAntennaModel> a = Create<IsotropicAntennaModel> (); | 64 Ptr<IsotropicAntennaModel> a = Create<IsotropicAntennaModel> (); |
64 double actualGain = a->GetGainDb (m_a); | 65 Vector v = CalculateNewPoint (Vector (0, 0, 0), m_a, 1); |
| 66 Ptr<ConstantPositionMobilityModel> cm1 = CreateObject<ConstantPositionMobility
Model> (); |
| 67 cm1->SetAttribute ("Position", VectorValue(Vector (0, 0, 0))); |
| 68 Ptr<ConstantPositionMobilityModel> cm2 = CreateObject<ConstantPositionMobility
Model> (); |
| 69 cm2->SetAttribute ("Position", VectorValue(v)); |
| 70 |
| 71 double actualGain = a->GetGainDb (cm1, cm2); |
65 NS_TEST_EXPECT_MSG_EQ_TOL (actualGain, m_expectedGain, 0.01, "wrong value of t
he radiation pattern"); | 72 NS_TEST_EXPECT_MSG_EQ_TOL (actualGain, m_expectedGain, 0.01, "wrong value of t
he radiation pattern"); |
66 } | 73 } |
67 | 74 |
68 | 75 |
69 | 76 |
70 | 77 |
71 class IsotropicAntennaModelTestSuite : public TestSuite | 78 class IsotropicAntennaModelTestSuite : public TestSuite |
72 { | 79 { |
73 public: | 80 public: |
74 IsotropicAntennaModelTestSuite (); | 81 IsotropicAntennaModelTestSuite (); |
(...skipping 13 matching lines...) Expand all Loading... |
88 AddTestCase (new IsotropicAntennaModelTestCase (Angles (M_PI_2, M_PI_2), 0.0))
; | 95 AddTestCase (new IsotropicAntennaModelTestCase (Angles (M_PI_2, M_PI_2), 0.0))
; |
89 | 96 |
90 }; | 97 }; |
91 | 98 |
92 static IsotropicAntennaModelTestSuite staticIsotropicAntennaModelTestSuiteInstan
ce; | 99 static IsotropicAntennaModelTestSuite staticIsotropicAntennaModelTestSuiteInstan
ce; |
93 | 100 |
94 | 101 |
95 | 102 |
96 | 103 |
97 } // namespace ns3 | 104 } // namespace ns3 |
OLD | NEW |