A Discrete-Event Network Simulator
API
spectrum-test.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  * Copyright (c) 2011 CTTC
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Nicola Baldo <nbaldo@cttc.es>
20  * part of the code copied from test.h
21  */
22 
23 #include <ns3/test.h>
24 #include <ns3/spectrum-value.h>
25 
26 
48 #define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
49  do \
50  { \
51  Bands::const_iterator i = (actual).Begin (); \
52  Bands::const_iterator j = (expected).Begin (); \
53  uint32_t k = 0; \
54  while (i != (actual).End () && j != (expected).End ()) \
55  { \
56  if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) \
57  || (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) \
58  || (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
59  { \
60  ASSERT_ON_FAILURE; \
61  std::ostringstream indexStream; \
62  indexStream << "[" << k << "]"; \
63  std::ostringstream msgStream; \
64  msgStream << (msg); \
65  std::ostringstream actualStream; \
66  actualStream << i->fl << " <-- " << i->fc << " --> " << i->fh; \
67  std::ostringstream expectedStream; \
68  expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
69  ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
70  actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
71  CONTINUE_ON_FAILURE; \
72  } \
73  ++i; \
74  ++j; \
75  ++k; \
76  } \
77  if (i != (actual).End () || j != (expected).End ()) \
78  { \
79  std::ostringstream msgStream; \
80  msgStream << (msg); \
81  std::ostringstream actualStream; \
82  actualStream << (i != (actual).End ()); \
83  std::ostringstream expectedStream; \
84  expectedStream << (j != (expected).End ()); \
85  ReportTestFailure ("Bands::iterator == End ()", \
86  actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
87  } \
88  } \
89  while (false); \
90 
91 
107 #define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
108  do \
109  { \
110  Values::const_iterator i = (actual).ConstValuesBegin (); \
111  Values::const_iterator j = (expected).ConstValuesBegin (); \
112  uint32_t k = 0; \
113  while (i != (actual).ConstValuesEnd () && j != (expected).ConstValuesEnd ()) \
114  { \
115  if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \
116  { \
117  ASSERT_ON_FAILURE; \
118  std::ostringstream indexStream; \
119  indexStream << "[" << k << "]"; \
120  std::ostringstream msgStream; \
121  msgStream << msg; \
122  std::ostringstream actualStream; \
123  actualStream << actual; \
124  std::ostringstream expectedStream; \
125  expectedStream << expected; \
126  ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
127  actualStream.str (), expectedStream.str (), msgStream.str (), __FILE__, __LINE__); \
128  CONTINUE_ON_FAILURE; \
129  } \
130  ++i; \
131  ++j; \
132  ++k; \
133  } \
134  if (i != (actual).ConstValuesEnd () || j != (expected).ConstValuesEnd ()) \
135  { \
136  std::ostringstream msgStream; \
137  msgStream << (msg); \
138  std::ostringstream actualStream; \
139  actualStream << (i != (actual).ConstValuesEnd ()); \
140  std::ostringstream expectedStream; \
141  expectedStream << (j != (expected).ConstValuesEnd ()); \
142  ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()", \
143  actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
144  } \
145  } \
146  while (false); \
147 
148 
149 
150