17 #include <cxxtest/TestSuite.h> 19 #error "Should only be included in builds with testing enabled." 20 #endif // ifdef CXX_TEST 31 #define _TS_ASSERT_EQUALS_AVEC(f, l, expected, length, actual) \ 32 xms::ttAssertEqualsAVec(f, l, expected, length, actual) 36 #define TS_ASSERT_EQUALS_AVEC(expected, length, actual) \ 37 _TS_ASSERT_EQUALS_AVEC(__FILE__, __LINE__, expected, length, actual) 42 #define _TS_ASSERT_DELTA_VEC(f, l, a, b, delta) xms::ttAssertDeltaVec((f), (l), (a), (b), (delta)) 46 #define TS_ASSERT_DELTA_VEC(a, b, delta) _TS_ASSERT_DELTA_VEC(__FILE__, __LINE__, a, b, delta) 52 #define _TS_ASSERT_DELTA_VEC2D(f, l, a, b, delta) \ 53 xms::ttAssertDeltaVec2D((f), (l), (a), (b), (delta)) 58 #define TS_ASSERT_DELTA_VEC2D(a, b, delta) _TS_ASSERT_DELTA_VEC2D(__FILE__, __LINE__, a, b, delta) 63 #define _TS_ASSERT_EQUALS_VEC2D(f, l, expected, actual) \ 64 xms::ttAssertEqualsVec2D((f), (l), (expected), (actual)) 68 #define TS_ASSERT_EQUALS_VEC2D(expected, actual) \ 69 _TS_ASSERT_EQUALS_VEC2D(__FILE__, __LINE__, expected, actual) 75 #define _TS_ASSERT_DELTA_VECPT3D(f, l, a, b, delta) ttAssertDeltaVecPt3d(f, l, a, b, delta) 80 #define TS_ASSERT_DELTA_VECPT3D(a, b, delta) \ 81 _TS_ASSERT_DELTA_VECPT3D(__FILE__, __LINE__, a, b, delta) 86 #define TS_ASSERT_DELTA_VEC_MP3(a, b, delta) \ 87 _TS_ASSERT_DELTA_VECPT3D(__FILE__, __LINE__, a, b, delta) 93 #define _TS_ASSERT_DELTA_VECPT2D(f, l, a, b, delta) ttAssertDeltaVecPt2d(f, l, a, b, delta) 98 #define TS_ASSERT_DELTA_VECPT2D(a, b, delta) \ 99 _TS_ASSERT_DELTA_VECPT2D(__FILE__, __LINE__, a, b, delta) 104 #define TS_ASSERT_DELTA_VEC_MP2(a, b, delta) \ 105 _TS_ASSERT_DELTA_VECPT2D(__FILE__, __LINE__, a, b, delta) 110 #define _TS_ASSERT_DELTA_PT3D(f, l, a, b, delta) ttAssertDeltaPt3d(f, l, a, b, delta) 114 #define _TS_ASSERT_DELTA_PT2D(f, l, a, b, delta) ttAssertDeltaPt2d(f, l, a, b, delta); 118 #define TS_ASSERT_DELTA_PT3D(a, b, delta) _TS_ASSERT_DELTA_PT3D(__FILE__, __LINE__, a, b, delta) 122 #define TS_ASSERT_DELTA_PT2D(a, b, delta) _TS_ASSERT_DELTA_PT2D(__FILE__, __LINE__, a, b, delta) 127 #define _TS_ASSERT_TXT_FILES_EQUAL(f, l, a, b) xms::ttTextFilesEqual((f), (l), a, b) 131 #define TS_ASSERT_TXT_FILES_EQUAL(a, b) _TS_ASSERT_TXT_FILES_EQUAL(__FILE__, __LINE__, a, b) 136 #define _TS_ASSERT_STREAMS_EQUAL(f, l, a, b) xms::ttStreamsEqual((f), (l), a, b) 140 #define TS_ASSERT_STREAMS_EQUAL(a, b) _TS_ASSERT_STREAMS_EQUAL(__FILE__, __LINE__, a, b) 145 #define _TS_ASSERT_EQUALS_VEC(f, l, a, b) \ 147 if (a.size() != b.size()) \ 149 std::stringstream msg; \ 150 msg << "Incorrect size Expecting size: " << a.size() << " Found size: " << b.size(); \ 151 _TS_FAIL(f, l, msg.str().c_str()); \ 155 for (size_t iUnique = 0; iUnique < a.size(); ++iUnique) \ 157 if (a[iUnique] != b[iUnique]) \ 159 std::stringstream msg; \ 160 msg << "Incorrect value at position : " << iUnique << " Expecting: " << a[iUnique] \ 161 << " Found: " << b[iUnique]; \ 162 _TS_FAIL(f, l, msg.str().c_str()); \ 171 #define TS_ASSERT_EQUALS_VEC(a, b) _TS_ASSERT_EQUALS_VEC(__FILE__, __LINE__, a, b) 176 #define _TS_REQUIRE_NOT_NULL(f, l, pointer) \ 177 if (pointer == NULL) \ 179 _TS_FAIL(f, l, "Unexpected NULL pointer."); \ 185 #define TS_REQUIRE_NOT_NULL(pointer) _TS_REQUIRE_NOT_NULL(__FILE__, __LINE__, pointer) 190 #define _TS_ASSERT_STACKED_ERRORS(f, l, expected) ::xms::ttAssertStackedErrors(f, l, expected) 194 #define TS_ASSERT_STACKED_ERRORS(expected) _TS_ASSERT_STACKED_ERRORS(__FILE__, __LINE__, expected) 236 template <
class _T,
class _U,
class _V>
239 return (fabs((A) - (B)) <= (tolerance));
244 const std::string& a_fileBase,
245 const std::string& a_extension,
246 std::string& a_baseFilePath,
247 std::string& a_outFilePath);
250 const std::string& a_file1,
251 const std::string& a_file2);
253 bool ttTextFilesEqual(
const std::string& a_file1,
254 const std::string& a_file2,
255 std::string& a_message);
258 std::istream& a_strm1,
259 std::istream& a_strm2);
261 bool ttEqualPointsXYZ(
double a_x1,
269 bool ttEqualPointsXY(
const Pt3d& a_pt1,
const Pt3d& a_pt2,
double a_tolerance);
270 bool ttEqualPointsXY(
double a_x1,
double a_y1,
double a_x2,
double a_y2,
double a_tolerance);
280 template <
typename T,
typename U>
283 const std::vector<T>& a,
284 const std::vector<T>& b,
288 if (a.size() != b.size())
290 std::stringstream msg;
291 msg <<
"Incorrect size (" << a.size() <<
" != " << b.size() <<
")";
292 _TS_FAIL(f, l, msg.str().c_str());
297 for (
size_t i = 0; i < a.size(); ++i)
301 std::stringstream msg;
302 msg <<
"Incorrect value at position (" << i <<
"). " 303 <<
"(" << a.at(i) <<
" != " << b.at(i) <<
")" 304 <<
" within delta (" << delta <<
")";
305 _TS_FAIL(f, l, msg.str().c_str());
321 template <
typename T,
typename U>
324 const std::vector<std::vector<T>>& a,
325 const std::vector<std::vector<T>>& b,
329 if (a.size() != b.size())
331 std::stringstream msg;
332 msg <<
"Incorrect size (" << a.size() <<
" != " << b.size() <<
")";
333 _TS_FAIL(f, l, msg.str().c_str());
338 for (
size_t i = 0; i < a.size(); ++i)
340 if (a.at(i).size() != b.at(i).size())
342 std::stringstream msg;
343 msg <<
"Incorrect size (" << a.at(i).size() <<
" != " << b.at(i).size() <<
")";
344 _TS_FAIL(f, l, msg.str().c_str());
349 for (
size_t j = 0; j < a.at(i).size(); ++j)
353 std::stringstream msg;
354 msg <<
"Incorrect value at position (" << i <<
")(" << j <<
"). " 355 <<
"(" << a.at(i).at(j) <<
" != " << b.at(i).at(j) <<
")" 356 <<
" within delta (" << delta <<
")";
357 _TS_FAIL(f, l, msg.str().c_str());
378 size_t a_expectedLength,
379 const std::vector<T>& a_actual)
381 std::vector<T> expected(a_expected, a_expected + a_expectedLength);
392 template <
typename T>
395 const std::vector<std::vector<T>>& a,
396 const std::vector<std::vector<T>>& b)
399 if (a.size() != b.size())
401 std::stringstream msg;
402 msg <<
"Incorrect size (" << a.size() <<
" != " << b.size() <<
")";
403 _TS_FAIL(f, l, msg.str().c_str());
408 for (
size_t i = 0; i < a.size(); ++i)
410 if (a.at(i).size() != b.at(i).size())
412 std::stringstream msg;
413 msg <<
"Incorrect size (" << a.at(i).size() <<
" != " << b.at(i).size() <<
")";
414 _TS_FAIL(f, l, msg.str().c_str());
419 for (
size_t j = 0; j < a.at(i).size(); ++j)
421 if (a.at(i).at(j) != b.at(i).at(j))
423 std::stringstream msg;
424 msg <<
"Incorrect value at position (" << i <<
")(" << j <<
"). " 425 <<
"(" << a.at(i).at(j) <<
" != " << b.at(i).at(j) <<
")";
426 _TS_FAIL(f, l, msg.str().c_str());
453 std::stringstream msg;
454 msg <<
"(" << a_pt1 <<
"), != (" << a_pt2 <<
") within delta (" << a_delta <<
")";
455 _TS_FAIL(a_file, a_line, msg.str().c_str());
476 std::stringstream msg;
477 msg <<
"(" << a_pt1 <<
"), != (" << a_pt2 <<
") within delta (" << a_delta <<
")";
478 _TS_FAIL(a_file, a_line, msg.str().c_str());
490 template <
class Pt1,
class Pt2>
497 if (a_pts1.size() != a_pts2.size())
499 std::stringstream msg;
500 msg <<
"Incorrect size Expecting size: " << a_pts1.size() <<
" Found size: " << a_pts2.size();
501 _TS_FAIL(a_file, a_line, msg.str().c_str());
505 for (
size_t i = 0; i < a_pts1.size(); ++i)
508 a_pts2.
at(i).y, a_pts2.
at(i).z, a_delta))
510 std::stringstream msg;
511 msg <<
"Incorrect value at position : " << i <<
" Expecting: " << a_pts1.
at(i)
512 <<
" Found: " << a_pts2.
at(i);
513 _TS_FAIL(a_file, a_line, msg.str().c_str());
527 template <
class Pt1,
class Pt2>
534 if (a_pts1.size() != a_pts2.size())
536 std::stringstream msg;
537 msg <<
"Incorrect size Expecting size: " << a_pts1.size() <<
" Found size: " << a_pts2.size();
538 _TS_FAIL(a_file, a_line, msg.str().c_str());
542 for (
size_t i = 0; i < a_pts1.size(); ++i)
547 std::stringstream msg;
548 msg <<
"Incorrect value at position : " << i <<
" Expecting: " << a_pts1.
at(i)
549 <<
" Found: " << a_pts2.
at(i);
550 _TS_FAIL(a_file, a_line, msg.str().c_str());
Include this small header instead of pt.h.
Class to allow running in batch mode without ui elements. Currently only used for testing but it can ...
bool m_defaultSet
Has a default result value been set?
const T & at(unsigned int a) const
ETestMessagingState()
Constructor.
void ClearDefault()
Change to no default value set.
int GetDefault()
Get default value.
bool m_skippingMessages
Are messages being skipped?
void SetSkipping(bool a_)
Set if skipping messages.
void SetDefault(int a_)
Set default result value.
int m_defaultRetValue
Default return value.
bool DefaultValWasSet()
Was default value set (true) or has it been cleared?
bool GetSkipping()
Get if skipping messages.