onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 1 | [doctest] run with "--help" for options |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 2 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 3 | logging.cpp(0): |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 4 | TEST CASE: logging the counter of a loop |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 5 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 6 | logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! |
| 7 | values: CHECK( 1 != 1 ) |
| 8 | logged: current iteration of loop: |
| 9 | i := 0 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 10 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 11 | logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! |
| 12 | values: CHECK( 2 != 2 ) |
| 13 | logged: current iteration of loop: |
| 14 | i := 1 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 15 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 16 | logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! |
| 17 | values: CHECK( 4 != 4 ) |
| 18 | logged: current iteration of loop: |
| 19 | i := 2 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 20 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 21 | logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! |
| 22 | values: CHECK( 8 != 8 ) |
| 23 | logged: current iteration of loop: |
| 24 | i := 3 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 25 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 26 | logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! |
| 27 | values: CHECK( 16 != 16 ) |
| 28 | logged: current iteration of loop: |
| 29 | i := 4 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 30 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 31 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 32 | logging.cpp(0): |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 33 | TEST CASE: a test case that will end from an exception |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 34 | |
Viktor Kirilov | 17d984c | 2020-12-04 15:13:33 +0200 | [diff] [blame] | 35 | logging.cpp(0): ERROR: forcing the many captures to be stringified |
| 36 | logged: lots of captures: 42 42 42; |
| 37 | old way of capturing - using the streaming operator: 42 42 |
onqtam | 321f270 | 2017-05-01 19:14:58 +0300 | [diff] [blame] | 38 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 39 | logging.cpp(0): ERROR: CHECK( some_var == 666 ) is NOT correct! |
| 40 | values: CHECK( 42 == 666 ) |
| 41 | logged: someTests() returned: 42 |
| 42 | this should be printed if an exception is thrown even if no assert has failed: 42 |
| 43 | in a nested scope this should be printed as well: 42 |
| 44 | why is this not 666 ?! |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 45 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 46 | logging.cpp(0): ERROR: test case THREW exception: 0 |
| 47 | logged: someTests() returned: 42 |
| 48 | this should be printed if an exception is thrown even if no assert has failed: 42 |
| 49 | in a nested scope this should be printed as well: 42 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 50 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 51 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 52 | logging.cpp(0): |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 53 | TEST CASE: a test case that will end from an exception and should print the unprinted context |
| 54 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 55 | logging.cpp(0): ERROR: test case THREW exception: 0 |
| 56 | logged: should be printed even if an exception is thrown and no assert fails before that |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 57 | |
| 58 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 59 | logging.cpp(0): |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 60 | TEST CASE: third party asserts can report failures to doctest |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 61 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 62 | logging.cpp(0): ERROR: MY_ASSERT(false) |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 63 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 64 | logging.cpp(0): FATAL ERROR: MY_ASSERT_FATAL(false) |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 65 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 66 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 67 | logging.cpp(0): |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 68 | TEST CASE: explicit failures 1 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 69 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 70 | logging.cpp(0): ERROR: this should not end the test case, but mark it as failing |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 71 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 72 | logging.cpp(0): MESSAGE: reached! |
onqtam | 378d670 | 2017-04-19 11:30:03 +0300 | [diff] [blame] | 73 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 74 | =============================================================================== |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 75 | logging.cpp(0): |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 76 | TEST CASE: explicit failures 2 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 77 | |
onqtam | 1655b24 | 2018-05-10 15:29:21 +0300 | [diff] [blame] | 78 | logging.cpp(0): FATAL ERROR: fail the test case and also end it |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 79 | |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 80 | =============================================================================== |
Nick Black | 74b8ac4 | 2020-09-06 13:01:26 -0400 | [diff] [blame] | 81 | [doctest] test cases: 6 | 0 passed | 6 failed | |
| 82 | [doctest] assertions: 11 | 0 passed | 11 failed | |
onqtam | 754f402 | 2017-05-06 20:07:49 +0300 | [diff] [blame] | 83 | [doctest] Status: FAILURE! |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 84 | Program code. |