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
24using namespace ns3;
25
26NS_LOG_COMPONENT_DEFINE("LteTestEarfcn");
27
37{
38 public:
46 LteEarfcnTestCase(const char* str, uint32_t earfcn, double f);
47 ~LteEarfcnTestCase() override;
48
49 protected:
51 double m_f;
52
53 private:
54 void DoRun() override;
55};
56
57LteEarfcnTestCase::LteEarfcnTestCase(const char* str, uint32_t earfcn, double f)
58 : TestCase(str),
59 m_earfcn(earfcn),
60 m_f(f)
61{
62 NS_LOG_FUNCTION(this << str << earfcn << f);
63}
64
66{
67}
68
69void
71{
72 double f = LteSpectrumValueHelper::GetCarrierFrequency(m_earfcn);
73 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
74}
75
86{
87 public:
95 LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f);
96
97 private:
98 void DoRun() override;
99};
100
102 : LteEarfcnTestCase(str, earfcn, f)
103{
104}
105
106void
108{
109 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
110 // LogComponentEnable ("LteSpectrumValueHelper", logLevel);
111 // LogComponentEnable ("LteTestEarfcn", logLevel);
112
113 double f = LteSpectrumValueHelper::GetDownlinkCarrierFrequency(m_earfcn);
114 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
115}
116
126{
127 public:
135 LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f);
136
137 private:
138 void DoRun() override;
139};
140
142 : LteEarfcnTestCase(str, earfcn, f)
143{
144}
145
146void
148{
149 double f = LteSpectrumValueHelper::GetUplinkCarrierFrequency(m_earfcn);
150 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
151}
152
161{
162 public:
164};
165
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:71
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:305
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 ",...
#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
static LteEarfcnTestSuite g_lteEarfcnTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.