58 /** |
58 /** |
59 * \internal |
59 * \internal |
60 */ |
60 */ |
61 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \ |
61 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \ |
62 do { \ |
62 do { \ |
63 if (!((actual) == (limit))) \ |
63 if (!((actual) == (limit))) \ |
64 { \ |
64 { \ |
65 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
65 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
66 std::ostringstream msgStream; \ |
66 std::ostringstream msgStream; \ |
67 msgStream << msg; \ |
67 msgStream << msg; \ |
68 std::ostringstream actualStream; \ |
68 std::ostringstream actualStream; \ |
69 actualStream << actual; \ |
69 actualStream << actual; \ |
70 std::ostringstream limitStream; \ |
70 std::ostringstream limitStream; \ |
71 limitStream << limit; \ |
71 limitStream << limit; \ |
72 ReportTestFailure (std::string (#actual) + " (actual) == " + std::string (#limit) + " (limit)", \ |
72 ReportTestFailure (std::string (# actual) + " (actual) == " + std::string (# limit) + " (limit)", \ |
73 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
73 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
74 if (!ContinueOnFailure ()) \ |
74 if (!ContinueOnFailure ()) \ |
75 { \ |
75 { \ |
76 return; \ |
76 return; \ |
77 } \ |
77 } \ |
78 } \ |
78 } \ |
79 } while (false) |
79 } while (false) |
80 |
80 |
81 /** |
81 /** |
82 * \brief Test that an actual and expected (limit) value are equal and report |
82 * \brief Test that an actual and expected (limit) value are equal and report |
83 * and abort if not. |
83 * and abort if not. |
84 * |
84 * |
110 /** |
110 /** |
111 * \internal |
111 * \internal |
112 */ |
112 */ |
113 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \ |
113 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \ |
114 do { \ |
114 do { \ |
115 if (!((actual) == (limit))) \ |
115 if (!((actual) == (limit))) \ |
116 { \ |
116 { \ |
117 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
117 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
118 std::ostringstream msgStream; \ |
118 std::ostringstream msgStream; \ |
119 msgStream << msg; \ |
119 msgStream << msg; \ |
120 std::ostringstream actualStream; \ |
120 std::ostringstream actualStream; \ |
121 actualStream << actual; \ |
121 actualStream << actual; \ |
122 std::ostringstream limitStream; \ |
122 std::ostringstream limitStream; \ |
123 limitStream << limit; \ |
123 limitStream << limit; \ |
124 ReportTestFailure (std::string (#actual) + " (actual) == " + std::string (#limit) + " (limit)", \ |
124 ReportTestFailure (std::string (# actual) + " (actual) == " + std::string (# limit) + " (limit)", \ |
125 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
125 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
126 if (!ContinueOnFailure ()) \ |
126 if (!ContinueOnFailure ()) \ |
127 { \ |
127 { \ |
128 return true; \ |
128 return true; \ |
129 } \ |
129 } \ |
130 } \ |
130 } \ |
131 } while (false) |
131 } while (false) |
132 |
132 |
133 /** |
133 /** |
134 * \brief Test that an actual and expected (limit) value are equal and report |
134 * \brief Test that an actual and expected (limit) value are equal and report |
135 * and abort if not. |
135 * and abort if not. |
136 * |
136 * |
168 * Required to avoid use of return statement which allows use in methods |
168 * Required to avoid use of return statement which allows use in methods |
169 * (esp. callbacks) returning void. |
169 * (esp. callbacks) returning void. |
170 */ |
170 */ |
171 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \ |
171 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \ |
172 do { \ |
172 do { \ |
173 if (!((actual) == (limit))) \ |
173 if (!((actual) == (limit))) \ |
174 { \ |
174 { \ |
175 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
175 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
176 std::ostringstream msgStream; \ |
176 std::ostringstream msgStream; \ |
177 msgStream << msg; \ |
177 msgStream << msg; \ |
178 std::ostringstream actualStream; \ |
178 std::ostringstream actualStream; \ |
179 actualStream << actual; \ |
179 actualStream << actual; \ |
180 std::ostringstream limitStream; \ |
180 std::ostringstream limitStream; \ |
181 limitStream << limit; \ |
181 limitStream << limit; \ |
182 ReportTestFailure (std::string (#actual) + " (actual) == " + std::string (#limit) + " (limit)", \ |
182 ReportTestFailure (std::string (# actual) + " (actual) == " + std::string (# limit) + " (limit)", \ |
183 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
183 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
184 } \ |
184 } \ |
185 } while (false) |
185 } while (false) |
186 |
186 |
187 /** |
187 /** |
188 * \brief Test that an actual and expected (limit) value are equal and report |
188 * \brief Test that an actual and expected (limit) value are equal and report |
189 * if not. |
189 * if not. |
190 * |
190 * |
221 /** |
221 /** |
222 * \internal |
222 * \internal |
223 */ |
223 */ |
224 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
224 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
225 do { \ |
225 do { \ |
226 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
226 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
227 { \ |
227 { \ |
228 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
228 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
229 std::ostringstream msgStream; \ |
229 std::ostringstream msgStream; \ |
230 msgStream << msg; \ |
230 msgStream << msg; \ |
231 std::ostringstream actualStream; \ |
231 std::ostringstream actualStream; \ |
232 actualStream << actual; \ |
232 actualStream << actual; \ |
233 std::ostringstream limitStream; \ |
233 std::ostringstream limitStream; \ |
234 limitStream << limit << " +- " << tol; \ |
234 limitStream << limit << " +- " << tol; \ |
235 std::ostringstream condStream; \ |
235 std::ostringstream condStream; \ |
236 condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol << " (tol) && " << \ |
236 condStream << # actual << " (actual) < " << # limit << " (limit) + " << # tol << " (tol) && " << \ |
237 #actual << " (actual) > " << #limit << " (limit) - " << #tol << " (tol)"; \ |
237 # actual << " (actual) > " << # limit << " (limit) - " << # tol << " (tol)"; \ |
238 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
238 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
239 if (!ContinueOnFailure ()) \ |
239 if (!ContinueOnFailure ()) \ |
240 { \ |
240 { \ |
241 return; \ |
241 return; \ |
242 } \ |
242 } \ |
243 } \ |
243 } \ |
244 } while (false) |
244 } while (false) |
245 |
245 |
246 /** |
246 /** |
247 * \brief Test that actual and expected (limit) values are equal to plus or minus |
247 * \brief Test that actual and expected (limit) values are equal to plus or minus |
248 * some tolerance and report and abort if not. |
248 * some tolerance and report and abort if not. |
249 * |
249 * |
297 /** |
297 /** |
298 * \internal |
298 * \internal |
299 */ |
299 */ |
300 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
300 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
301 do { \ |
301 do { \ |
302 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
302 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
303 { \ |
303 { \ |
304 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
304 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
305 std::ostringstream msgStream; \ |
305 std::ostringstream msgStream; \ |
306 msgStream << msg; \ |
306 msgStream << msg; \ |
307 std::ostringstream actualStream; \ |
307 std::ostringstream actualStream; \ |
308 actualStream << actual; \ |
308 actualStream << actual; \ |
309 std::ostringstream limitStream; \ |
309 std::ostringstream limitStream; \ |
310 limitStream << limit << " +- " << tol; \ |
310 limitStream << limit << " +- " << tol; \ |
311 std::ostringstream condStream; \ |
311 std::ostringstream condStream; \ |
312 condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol << " (tol) && " << \ |
312 condStream << # actual << " (actual) < " << # limit << " (limit) + " << # tol << " (tol) && " << \ |
313 #actual << " (actual) > " << #limit << " (limit) - " << #tol << " (tol)"; \ |
313 # actual << " (actual) > " << # limit << " (limit) - " << # tol << " (tol)"; \ |
314 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
314 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
315 if (!ContinueOnFailure ()) \ |
315 if (!ContinueOnFailure ()) \ |
316 { \ |
316 { \ |
317 return true; \ |
317 return true; \ |
318 } \ |
318 } \ |
319 } \ |
319 } \ |
320 } while (false) |
320 } while (false) |
321 |
321 |
322 /** |
322 /** |
323 * \brief Test that actual and expected (limit) values are equal to plus or minus |
323 * \brief Test that actual and expected (limit) values are equal to plus or minus |
324 * some tolerance and report and abort if not. |
324 * some tolerance and report and abort if not. |
325 * |
325 * |
379 * Required to avoid use of return statement which allows use in methods |
379 * Required to avoid use of return statement which allows use in methods |
380 * (esp. callbacks) returning void. |
380 * (esp. callbacks) returning void. |
381 */ |
381 */ |
382 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
382 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \ |
383 do { \ |
383 do { \ |
384 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
384 if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ |
385 { \ |
385 { \ |
386 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
386 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
387 std::ostringstream msgStream; \ |
387 std::ostringstream msgStream; \ |
388 msgStream << msg; \ |
388 msgStream << msg; \ |
389 std::ostringstream actualStream; \ |
389 std::ostringstream actualStream; \ |
390 actualStream << actual; \ |
390 actualStream << actual; \ |
391 std::ostringstream limitStream; \ |
391 std::ostringstream limitStream; \ |
392 limitStream << limit << " +- " << tol; \ |
392 limitStream << limit << " +- " << tol; \ |
393 std::ostringstream condStream; \ |
393 std::ostringstream condStream; \ |
394 condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol << " (tol) && " << \ |
394 condStream << # actual << " (actual) < " << # limit << " (limit) + " << # tol << " (tol) && " << \ |
395 #actual << " (actual) > " << #limit << " (limit) - " << #tol << " (tol)"; \ |
395 # actual << " (actual) > " << # limit << " (limit) - " << # tol << " (tol)"; \ |
396 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
396 ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
397 } \ |
397 } \ |
398 } while (false) |
398 } while (false) |
399 |
399 |
400 /** |
400 /** |
401 * \brief Test that actual and expected (limit) values are equal to plus or minus |
401 * \brief Test that actual and expected (limit) values are equal to plus or minus |
402 * some tolerance and report if not. |
402 * some tolerance and report if not. |
403 * |
403 * |
455 /** |
455 /** |
456 * \internal |
456 * \internal |
457 */ |
457 */ |
458 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \ |
458 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \ |
459 do { \ |
459 do { \ |
460 if (!((actual) != (limit))) \ |
460 if (!((actual) != (limit))) \ |
461 { \ |
461 { \ |
462 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
462 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
463 std::ostringstream msgStream; \ |
463 std::ostringstream msgStream; \ |
464 msgStream << msg; \ |
464 msgStream << msg; \ |
465 std::ostringstream actualStream; \ |
465 std::ostringstream actualStream; \ |
466 actualStream << actual; \ |
466 actualStream << actual; \ |
467 std::ostringstream limitStream; \ |
467 std::ostringstream limitStream; \ |
468 limitStream << limit; \ |
468 limitStream << limit; \ |
469 ReportTestFailure (std::string (#actual) + " (actual) != " + std::string (#limit) + " (limit)", \ |
469 ReportTestFailure (std::string (# actual) + " (actual) != " + std::string (# limit) + " (limit)", \ |
470 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
470 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
471 if (!ContinueOnFailure ()) \ |
471 if (!ContinueOnFailure ()) \ |
472 { \ |
472 { \ |
473 return; \ |
473 return; \ |
474 } \ |
474 } \ |
475 } \ |
475 } \ |
476 } while (false) |
476 } while (false) |
477 |
477 |
478 /** |
478 /** |
479 * \brief Test that an actual and expected (limit) value are equal and report |
479 * \brief Test that an actual and expected (limit) value are equal and report |
480 * and abort if not. |
480 * and abort if not. |
481 * |
481 * |
506 /** |
506 /** |
507 * \internal |
507 * \internal |
508 */ |
508 */ |
509 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \ |
509 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \ |
510 do { \ |
510 do { \ |
511 if (!((actual) != (limit))) \ |
511 if (!((actual) != (limit))) \ |
512 { \ |
512 { \ |
513 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
513 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
514 std::ostringstream msgStream; \ |
514 std::ostringstream msgStream; \ |
515 msgStream << msg; \ |
515 msgStream << msg; \ |
516 std::ostringstream actualStream; \ |
516 std::ostringstream actualStream; \ |
517 actualStream << actual; \ |
517 actualStream << actual; \ |
518 std::ostringstream limitStream; \ |
518 std::ostringstream limitStream; \ |
519 limitStream << limit; \ |
519 limitStream << limit; \ |
520 ReportTestFailure (std::string (#actual) + " (actual) != " + std::string (#limit) + " (limit)", \ |
520 ReportTestFailure (std::string (# actual) + " (actual) != " + std::string (# limit) + " (limit)", \ |
521 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
521 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
522 if (!ContinueOnFailure ()) \ |
522 if (!ContinueOnFailure ()) \ |
523 { \ |
523 { \ |
524 return true; \ |
524 return true; \ |
525 } \ |
525 } \ |
526 } \ |
526 } \ |
527 } while (false) |
527 } while (false) |
528 |
528 |
529 /** |
529 /** |
530 * \brief Test that an actual and expected (limit) value are equal and report |
530 * \brief Test that an actual and expected (limit) value are equal and report |
531 * and abort if not. |
531 * and abort if not. |
532 * |
532 * |
563 * Required to avoid use of return statement which allows use in methods |
563 * Required to avoid use of return statement which allows use in methods |
564 * (callbacks) returning void. |
564 * (callbacks) returning void. |
565 */ |
565 */ |
566 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \ |
566 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \ |
567 do { \ |
567 do { \ |
568 if (!((actual) != (limit))) \ |
568 if (!((actual) != (limit))) \ |
569 { \ |
569 { \ |
570 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
570 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
571 std::ostringstream msgStream; \ |
571 std::ostringstream msgStream; \ |
572 msgStream << msg; \ |
572 msgStream << msg; \ |
573 std::ostringstream actualStream; \ |
573 std::ostringstream actualStream; \ |
574 actualStream << actual; \ |
574 actualStream << actual; \ |
575 std::ostringstream limitStream; \ |
575 std::ostringstream limitStream; \ |
576 limitStream << limit; \ |
576 limitStream << limit; \ |
577 ReportTestFailure (std::string (#actual) + " (actual) != " + std::string (#limit) + " (limit)", \ |
577 ReportTestFailure (std::string (# actual) + " (actual) != " + std::string (# limit) + " (limit)", \ |
578 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
578 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
579 } \ |
579 } \ |
580 } while (false) |
580 } while (false) |
581 |
581 |
582 /** |
582 /** |
583 * \brief Test that an actual and expected (limit) value are equal and report |
583 * \brief Test that an actual and expected (limit) value are equal and report |
584 * if not. |
584 * if not. |
585 * |
585 * |
614 /** |
614 /** |
615 * \internal |
615 * \internal |
616 */ |
616 */ |
617 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \ |
617 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \ |
618 do { \ |
618 do { \ |
619 if (!((actual) < (limit))) \ |
619 if (!((actual) < (limit))) \ |
620 { \ |
620 { \ |
621 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
621 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
622 std::ostringstream msgStream; \ |
622 std::ostringstream msgStream; \ |
623 msgStream << msg; \ |
623 msgStream << msg; \ |
624 std::ostringstream actualStream; \ |
624 std::ostringstream actualStream; \ |
625 actualStream << actual; \ |
625 actualStream << actual; \ |
626 std::ostringstream limitStream; \ |
626 std::ostringstream limitStream; \ |
627 limitStream << limit; \ |
627 limitStream << limit; \ |
628 ReportTestFailure (std::string (#actual) + " (actual) < " + std::string (#limit) + " (limit)", \ |
628 ReportTestFailure (std::string (# actual) + " (actual) < " + std::string (# limit) + " (limit)", \ |
629 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
629 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
630 if (!ContinueOnFailure ()) \ |
630 if (!ContinueOnFailure ()) \ |
631 { \ |
631 { \ |
632 return; \ |
632 return; \ |
633 } \ |
633 } \ |
634 } \ |
634 } \ |
635 } while (false) |
635 } while (false) |
636 |
636 |
637 /** |
637 /** |
638 * \brief Test that an actual value is less than a limit and report and abort |
638 * \brief Test that an actual value is less than a limit and report and abort |
639 * if not. |
639 * if not. |
640 * |
640 * |
658 * Required to avoid use of return statement which allows use in methods |
658 * Required to avoid use of return statement which allows use in methods |
659 * (callbacks) returning void. |
659 * (callbacks) returning void. |
660 */ |
660 */ |
661 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \ |
661 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \ |
662 do { \ |
662 do { \ |
663 if (!((actual) < (limit))) \ |
663 if (!((actual) < (limit))) \ |
664 { \ |
664 { \ |
665 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
665 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
666 std::ostringstream msgStream; \ |
666 std::ostringstream msgStream; \ |
667 msgStream << msg; \ |
667 msgStream << msg; \ |
668 std::ostringstream actualStream; \ |
668 std::ostringstream actualStream; \ |
669 actualStream << actual; \ |
669 actualStream << actual; \ |
670 std::ostringstream limitStream; \ |
670 std::ostringstream limitStream; \ |
671 limitStream << limit; \ |
671 limitStream << limit; \ |
672 ReportTestFailure (std::string (#actual) + " (actual) < " + std::string (#limit) + " (limit)", \ |
672 ReportTestFailure (std::string (# actual) + " (actual) < " + std::string (# limit) + " (limit)", \ |
673 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
673 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
674 } \ |
674 } \ |
675 } while (false) |
675 } while (false) |
676 |
676 |
677 /** |
677 /** |
678 * \brief Test that an actual value is less than a limit and report if not. |
678 * \brief Test that an actual value is less than a limit and report if not. |
679 * |
679 * |
680 * Check to see if the actual value found in a test case is less than the |
680 * Check to see if the actual value found in a test case is less than the |
698 /** |
698 /** |
699 * \internal |
699 * \internal |
700 */ |
700 */ |
701 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \ |
701 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \ |
702 do { \ |
702 do { \ |
703 if (!((actual) > (limit))) \ |
703 if (!((actual) > (limit))) \ |
704 { \ |
704 { \ |
705 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
705 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
706 std::ostringstream msgStream; \ |
706 std::ostringstream msgStream; \ |
707 msgStream << msg; \ |
707 msgStream << msg; \ |
708 std::ostringstream actualStream; \ |
708 std::ostringstream actualStream; \ |
709 actualStream << actual; \ |
709 actualStream << actual; \ |
710 std::ostringstream limitStream; \ |
710 std::ostringstream limitStream; \ |
711 limitStream << limit; \ |
711 limitStream << limit; \ |
712 ReportTestFailure (std::string (#actual) + " (actual) > " + std::string (#limit) + " (limit)", \ |
712 ReportTestFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)", \ |
713 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
713 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
714 if (!ContinueOnFailure ()) \ |
714 if (!ContinueOnFailure ()) \ |
715 { \ |
715 { \ |
716 return; \ |
716 return; \ |
717 } \ |
717 } \ |
718 } \ |
718 } \ |
719 } while (false) |
719 } while (false) |
720 |
720 |
721 /** |
721 /** |
722 * \brief Test that an actual value is greater than a limit and report and abort |
722 * \brief Test that an actual value is greater than a limit and report and abort |
723 * if not. |
723 * if not. |
724 * |
724 * |
742 * Required to avoid use of return statement which allows use in methods |
742 * Required to avoid use of return statement which allows use in methods |
743 * (callbacks) returning void. |
743 * (callbacks) returning void. |
744 */ |
744 */ |
745 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \ |
745 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \ |
746 do { \ |
746 do { \ |
747 if (!((actual) > (limit))) \ |
747 if (!((actual) > (limit))) \ |
748 { \ |
748 { \ |
749 if (gBreakOnFailure) {*(int *)0 = 0;} \ |
749 if (gBreakOnFailure) { *(int *)0 = 0;} \ |
750 std::ostringstream msgStream; \ |
750 std::ostringstream msgStream; \ |
751 msgStream << msg; \ |
751 msgStream << msg; \ |
752 std::ostringstream actualStream; \ |
752 std::ostringstream actualStream; \ |
753 actualStream << actual; \ |
753 actualStream << actual; \ |
754 std::ostringstream limitStream; \ |
754 std::ostringstream limitStream; \ |
755 limitStream << limit; \ |
755 limitStream << limit; \ |
756 ReporTesttFailure (std::string (#actual) + " (actual) > " + std::string (#limit) + " (limit)", \ |
756 ReporTesttFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)", \ |
757 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
757 actualStream.str (), limitStream.str (), msgStream.str (), file, line); \ |
758 } \ |
758 } \ |
759 } while (false) |
759 } while (false) |
760 |
760 |
761 /** |
761 /** |
762 * \brief Test that an actual value is greater than a limit and report if not. |
762 * \brief Test that an actual value is greater than a limit and report if not. |
763 * |
763 * |
764 * Check to see if the actual value found in a test case is greater than the |
764 * Check to see if the actual value found in a test case is greater than the |
793 * \param a The first of double precision floating point numbers to compare |
793 * \param a The first of double precision floating point numbers to compare |
794 * \param b The second of double precision floating point numbers to compare |
794 * \param b The second of double precision floating point numbers to compare |
795 * \param epsilon The second of double precision floating point numberss to compare |
795 * \param epsilon The second of double precision floating point numberss to compare |
796 * \returns Returns true if the doubles are equal to a precision defined by epsilon |
796 * \returns Returns true if the doubles are equal to a precision defined by epsilon |
797 */ |
797 */ |
798 bool TestDoubleIsEqual (const double a, const double b, const double epsilon = std::numeric_limits<double>::epsilon ()); |
798 bool TestDoubleIsEqual (const double a, const double b, const double epsilon = std::numeric_limits<double>::epsilon ()); |
799 |
799 |
800 /** |
800 /** |
801 * \brief A single test case. |
801 * \brief A single test case. |
802 */ |
802 */ |
803 class TestCase |
803 class TestCase |
841 void SetName (std::string name); |
841 void SetName (std::string name); |
842 |
842 |
843 /** |
843 /** |
844 * \brief Get the name of this test case. |
844 * \brief Get the name of this test case. |
845 */ |
845 */ |
846 std::string GetName (void); |
846 std::string GetName (void); |
847 |
847 |
848 /** |
848 /** |
849 * \brief Set the base directory of the ns-3 distribution. |
849 * \brief Set the base directory of the ns-3 distribution. |
850 */ |
850 */ |
851 void SetBaseDir (std::string dir); |
851 void SetBaseDir (std::string dir); |
960 /** |
960 /** |
961 * \brief Issue a test report than the test case has found an error and |
961 * \brief Issue a test report than the test case has found an error and |
962 * report the details. |
962 * report the details. |
963 */ |
963 */ |
964 void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, |
964 void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, |
965 std::string file, int32_t line); |
965 std::string file, int32_t line); |
966 |
966 |
967 /** |
967 /** |
968 * \brief Issue a test report than the test case has completed its run. |
968 * \brief Issue a test report than the test case has completed its run. |
969 */ |
969 */ |
970 void ReportEnd (void); |
970 void ReportEnd (void); |
991 /** |
991 /** |
992 * \internal |
992 * \internal |
993 * \brief Implementation of reporting method for failure of the test case. |
993 * \brief Implementation of reporting method for failure of the test case. |
994 */ |
994 */ |
995 virtual void DoReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, |
995 virtual void DoReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, |
996 std::string file, int32_t line); |
996 std::string file, int32_t line); |
997 |
997 |
998 /** |
998 /** |
999 * \internal |
999 * \internal |
1000 * \brief Implementation of reporting method for the end of the test case. |
1000 * \brief Implementation of reporting method for the end of the test case. |
1001 */ |
1001 */ |
1131 void SetName (std::string name); |
1131 void SetName (std::string name); |
1132 |
1132 |
1133 /** |
1133 /** |
1134 * \brief Get the name of this test suite. |
1134 * \brief Get the name of this test suite. |
1135 */ |
1135 */ |
1136 std::string GetName (void); |
1136 std::string GetName (void); |
1137 |
1137 |
1138 /** |
1138 /** |
1139 * \brief Set the base directory of the ns-3 distribution. |
1139 * \brief Set the base directory of the ns-3 distribution. |
1140 */ |
1140 */ |
1141 void SetBaseDir (std::string basedir); |
1141 void SetBaseDir (std::string basedir); |