A Discrete-Event Network Simulator
API
lte-test-earfcn.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (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/log.h"
21 #include "ns3/lte-spectrum-value-helper.h"
22 #include "ns3/test.h"
23 
24 using namespace ns3;
25 
26 NS_LOG_COMPONENT_DEFINE("LteTestEarfcn");
27 
36 {
37  public:
45  LteEarfcnTestCase(const char* str, uint32_t earfcn, double f);
46  ~LteEarfcnTestCase() override;
47 
48  protected:
49  uint32_t m_earfcn;
50  double m_f;
51 
52  private:
53  void DoRun() override;
54 };
55 
56 LteEarfcnTestCase::LteEarfcnTestCase(const char* str, uint32_t earfcn, double f)
57  : TestCase(str),
58  m_earfcn(earfcn),
59  m_f(f)
60 {
61  NS_LOG_FUNCTION(this << str << earfcn << f);
62 }
63 
65 {
66 }
67 
68 void
70 {
71  double f = LteSpectrumValueHelper::GetCarrierFrequency(m_earfcn);
72  NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
73 }
74 
84 {
85  public:
93  LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f);
94 
95  private:
96  void DoRun() override;
97 };
98 
99 LteEarfcnDlTestCase::LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f)
100  : LteEarfcnTestCase(str, earfcn, f)
101 {
102 }
103 
104 void
106 {
107  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
108  // LogComponentEnable ("LteSpectrumValueHelper", logLevel);
109  // LogComponentEnable ("LteTestEarfcn", logLevel);
110 
111  double f = LteSpectrumValueHelper::GetDownlinkCarrierFrequency(m_earfcn);
112  NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
113 }
114 
123 {
124  public:
132  LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f);
133 
134  private:
135  void DoRun() override;
136 };
137 
138 LteEarfcnUlTestCase::LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f)
139  : LteEarfcnTestCase(str, earfcn, f)
140 {
141 }
142 
143 void
145 {
146  double f = LteSpectrumValueHelper::GetUplinkCarrierFrequency(m_earfcn);
147  NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
148 }
149 
157 {
158  public:
160 };
161 
167 
169  : TestSuite("lte-earfcn", UNIT)
170 {
171  NS_LOG_FUNCTION(this);
172 
173  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=500", 500, 2160e6), TestCase::QUICK);
174  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
175  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
176  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=7000", 7000, 0.0), TestCase::QUICK);
177  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=20000", 20000, 0.0), TestCase::QUICK);
178  AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
179 
180  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
181  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
182  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
183  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=10", 10, 0.0), TestCase::QUICK);
184  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=1000", 1000, 0.0), TestCase::QUICK);
185  AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
186 
187  AddTestCase(new LteEarfcnTestCase("EARFCN=500", 500, 2160e6), TestCase::QUICK);
188  AddTestCase(new LteEarfcnTestCase("EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
189  AddTestCase(new LteEarfcnTestCase("EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
190  AddTestCase(new LteEarfcnTestCase("EARFCN=8000", 8000, 0.0), TestCase::QUICK);
191  AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
192  AddTestCase(new LteEarfcnTestCase("EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
193  AddTestCase(new LteEarfcnTestCase("EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
194  AddTestCase(new LteEarfcnTestCase("EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
195  AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
196 }
double f(double x, void *params)
Definition: 80211b.c:70
Test case that is testing if the downlink frequency is properly converted from provided downlink EARF...
LteEarfcnDlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test case that is testing if the frequency is properly generated from provided EARFCN frequency.
void DoRun() override
Implementation to actually run this TestCase.
~LteEarfcnTestCase() override
uint32_t m_earfcn
the EARFCN
double m_f
the frequency
LteEarfcnTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
Test suite for testing correct conversion of frequencies in the downlink and the uplink,...
Test case that is testing if the uplink frequency is properly converted from provided uplink EARFCN f...
LteEarfcnUlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteEarfcnTestSuite g_lteEarfcnTestSuite
Static variable for test initialization.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:337
Every class exported by the ns3 library is enclosed in the ns3 namespace.