A Discrete-Event Network Simulator
API
lte-test-earfcn.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (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
22
23#include "ns3/test.h"
24#include "ns3/log.h"
25
26#include "ns3/lte-spectrum-value-helper.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE ("LteTestEarfcn");
31
41{
42public:
50 LteEarfcnTestCase (const char* str, uint32_t earfcn, double f);
51 virtual ~LteEarfcnTestCase ();
52
53protected:
55 double m_f;
56
57private:
58 virtual void DoRun (void);
59};
60
61LteEarfcnTestCase::LteEarfcnTestCase (const char* str, uint32_t earfcn, double f)
62 : TestCase (str),
63 m_earfcn (earfcn),
64 m_f (f)
65{
66 NS_LOG_FUNCTION (this << str << earfcn << f);
67}
68
70{
71}
72
73void
75{
76 double f = LteSpectrumValueHelper::GetCarrierFrequency (m_earfcn);
77 NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
78}
79
90{
91public:
99 LteEarfcnDlTestCase (const char* str, uint32_t earfcn, double f);
100
101private:
102 virtual void DoRun (void);
103};
104
105LteEarfcnDlTestCase::LteEarfcnDlTestCase (const char* str, uint32_t earfcn, double f)
106 : LteEarfcnTestCase (str, earfcn, f)
107{
108}
109
110void
112{
113// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
114// LogComponentEnable ("LteSpectrumValueHelper", logLevel);
115// LogComponentEnable ("LteTestEarfcn", logLevel);
116
117 double f = LteSpectrumValueHelper::GetDownlinkCarrierFrequency (m_earfcn);
118 NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
119}
120
121
131{
132public:
140 LteEarfcnUlTestCase (const char* str, uint32_t earfcn, double f);
141
142private:
143 virtual void DoRun (void);
144};
145
146LteEarfcnUlTestCase::LteEarfcnUlTestCase (const char* str, uint32_t earfcn, double f)
147 : LteEarfcnTestCase (str, earfcn, f)
148{
149}
150
151void
153{
154 double f = LteSpectrumValueHelper::GetUplinkCarrierFrequency (m_earfcn);
155 NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
156}
157
158
167{
168public:
170};
171
173
175 : TestSuite ("lte-earfcn", UNIT)
176{
177 NS_LOG_FUNCTION (this);
178
179 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=500", 500, 2160e6), TestCase::QUICK);
180 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
181 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
182 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=7000", 7000, 0.0), TestCase::QUICK);
183 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=20000", 20000, 0.0), TestCase::QUICK);
184 AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
185
186 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
187 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
188 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
189 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=10", 10, 0.0), TestCase::QUICK);
190 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=1000", 1000, 0.0), TestCase::QUICK);
191 AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
192
193 AddTestCase (new LteEarfcnTestCase ("EARFCN=500", 500, 2160e6), TestCase::QUICK);
194 AddTestCase (new LteEarfcnTestCase ("EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
195 AddTestCase (new LteEarfcnTestCase ("EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
196 AddTestCase (new LteEarfcnTestCase ("EARFCN=8000", 8000, 0.0), TestCase::QUICK);
197 AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
198 AddTestCase (new LteEarfcnTestCase ("EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
199 AddTestCase (new LteEarfcnTestCase ("EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
200 AddTestCase (new LteEarfcnTestCase ("EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
201 AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
202}
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test case that is testing if the frequency is properly generated from provided EARFCN frequency.
virtual ~LteEarfcnTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
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...
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteEarfcnUlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:323
static LteEarfcnTestSuite g_lteEarfcnTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.