22 #ifndef SPECTRUM_TEST_H
23 #define SPECTRUM_TEST_H
25 #include <ns3/spectrum-value.h>
48 #define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
51 auto i = (actual).Begin(); \
52 auto j = (expected).Begin(); \
54 while (i != (actual).End() && j != (expected).End()) \
56 if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) || (i->fc > j->fc + (tol)) || \
57 (i->fc < j->fc - (tol)) || (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
60 std::ostringstream indexStream; \
61 indexStream << "[" << k << "]"; \
62 std::ostringstream msgStream; \
64 std::ostringstream actualStream; \
65 actualStream << i->fl << " <-- " << i->fc << " --> " << i->fh; \
66 std::ostringstream expectedStream; \
67 expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
68 ReportTestFailure(std::string(#actual) + indexStream.str() + \
69 " == " + std::string(#expected) + indexStream.str(), \
71 expectedStream.str(), \
75 CONTINUE_ON_FAILURE; \
81 if (i != (actual).End() || j != (expected).End()) \
83 std::ostringstream msgStream; \
85 std::ostringstream actualStream; \
86 actualStream << (i != (actual).End()); \
87 std::ostringstream expectedStream; \
88 expectedStream << (j != (expected).End()); \
89 ReportTestFailure("Bands::iterator == End ()", \
91 expectedStream.str(), \
113 #define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
116 auto i = (actual).ConstValuesBegin(); \
117 auto j = (expected).ConstValuesBegin(); \
119 while (i != (actual).ConstValuesEnd() && j != (expected).ConstValuesEnd()) \
121 if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \
124 std::ostringstream indexStream; \
125 indexStream << "[" << k << "]"; \
126 std::ostringstream msgStream; \
128 std::ostringstream actualStream; \
129 actualStream << actual; \
130 std::ostringstream expectedStream; \
131 expectedStream << expected; \
132 ReportTestFailure(std::string(#actual) + indexStream.str() + \
133 " == " + std::string(#expected) + indexStream.str(), \
134 actualStream.str(), \
135 expectedStream.str(), \
139 CONTINUE_ON_FAILURE; \
145 if (i != (actual).ConstValuesEnd() || j != (expected).ConstValuesEnd()) \
147 std::ostringstream msgStream; \
148 msgStream << (msg); \
149 std::ostringstream actualStream; \
150 actualStream << (i != (actual).ConstValuesEnd()); \
151 std::ostringstream expectedStream; \
152 expectedStream << (j != (expected).ConstValuesEnd()); \
153 ReportTestFailure("Values::const_iterator == ConstValuesEnd ()", \
154 actualStream.str(), \
155 expectedStream.str(), \