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 
28 using namespace ns3;
29 
30 NS_LOG_COMPONENT_DEFINE ("LteTestEarfcn");
31 
33 {
34 public:
35  LteEarfcnTestCase (const char* str, uint16_t earfcn, double f);
36  virtual ~LteEarfcnTestCase ();
37 
38 protected:
39  uint16_t m_earfcn;
40  double m_f;
41 
42 private:
43  virtual void DoRun (void);
44 };
45 
46 LteEarfcnTestCase::LteEarfcnTestCase (const char* str, uint16_t earfcn, double f)
47  : TestCase (str),
48  m_earfcn (earfcn),
49  m_f (f)
50 {
51  NS_LOG_FUNCTION (this << str << earfcn << f);
52 }
53 
55 {
56 }
57 
58 void
60 {
61  double f = LteSpectrumValueHelper::GetCarrierFrequency (m_earfcn);
62  NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
63 }
64 
66 {
67 public:
68  LteEarfcnDlTestCase (const char* str, uint16_t earfcn, double f);
69 
70 private:
71  virtual void DoRun (void);
72 };
73 
74 LteEarfcnDlTestCase::LteEarfcnDlTestCase (const char* str, uint16_t earfcn, double f)
75  : LteEarfcnTestCase (str, earfcn, f)
76 {
77 }
78 
79 void
81 {
82 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
83 // LogComponentEnable ("LteSpectrumValueHelper", logLevel);
84 // LogComponentEnable ("LteTestEarfcn", logLevel);
85 
86  double f = LteSpectrumValueHelper::GetDownlinkCarrierFrequency (m_earfcn);
87  NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
88 }
89 
90 
92 {
93 public:
94  LteEarfcnUlTestCase (const char* str, uint16_t earfcn, double f);
95 
96 private:
97  virtual void DoRun (void);
98 };
99 
100 LteEarfcnUlTestCase::LteEarfcnUlTestCase (const char* str, uint16_t earfcn, double f)
101  : LteEarfcnTestCase (str, earfcn, f)
102 {
103 }
104 
105 void
107 {
108  double f = LteSpectrumValueHelper::GetUplinkCarrierFrequency (m_earfcn);
109  NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");
110 }
111 
112 
117 {
118 public:
120 };
121 
123 
125  : TestSuite ("lte-earfcn", UNIT)
126 {
127  NS_LOG_FUNCTION (this);
128 
129  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=500", 500, 2160e6), TestCase::QUICK);
130  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
131  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
132  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=7000", 7000, 0.0), TestCase::QUICK);
133  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=20000", 20000, 0.0), TestCase::QUICK);
134  AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
135 
136  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
137  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
138  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
139  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=10", 10, 0.0), TestCase::QUICK);
140  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=1000", 1000, 0.0), TestCase::QUICK);
141  AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=50000", 50000, 0.0), TestCase::QUICK);
142 
143  AddTestCase (new LteEarfcnTestCase ("EARFCN=500", 500, 2160e6), TestCase::QUICK);
144  AddTestCase (new LteEarfcnTestCase ("EARFCN=1000", 1000, 1970e6), TestCase::QUICK);
145  AddTestCase (new LteEarfcnTestCase ("EARFCN=1301", 1301, 1815.1e6), TestCase::QUICK);
146  AddTestCase (new LteEarfcnTestCase ("EARFCN=8000", 8000, 0.0), TestCase::QUICK);
147  AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
148  AddTestCase (new LteEarfcnTestCase ("EARFCN=18100", 18100, 1930e6), TestCase::QUICK);
149  AddTestCase (new LteEarfcnTestCase ("EARFCN=19000", 19000, 1890e6), TestCase::QUICK);
150  AddTestCase (new LteEarfcnTestCase ("EARFCN=19400", 19400, 1730e6), TestCase::QUICK);
151  AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0), TestCase::QUICK);
152 }
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual ~LteEarfcnTestCase()
A suite of tests to run.
Definition: test.h:1333
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual void DoRun(void)
Implementation to actually run this TestCase.
encapsulates test code
Definition: test.h:1147
Test the calculation of carrier frequency based on EARFCN.
static LteEarfcnTestSuite g_lteEarfcnTestSuite
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
LteEarfcnTestCase(const char *str, uint16_t earfcn, double f)
#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:373
double f(double x, void *params)
Definition: 80211b.c:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LteEarfcnDlTestCase(const char *str, uint16_t earfcn, double f)
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteEarfcnUlTestCase(const char *str, uint16_t earfcn, double f)
virtual void DoRun(void)
Implementation to actually run this TestCase.