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 | cb7bad6 | 2017-04-19 11:19:57 +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 | |
| 6 | logging.cpp(0) ERROR! |
| 7 | CHECK( vec[i] != (1 << i) ) |
| 8 | with expansion: |
| 9 | CHECK( 1 != 1 ) |
| 10 | with context: |
| 11 | current iteration of loop: |
| 12 | i := 0 |
| 13 | |
| 14 | logging.cpp(0) ERROR! |
| 15 | CHECK( vec[i] != (1 << i) ) |
| 16 | with expansion: |
| 17 | CHECK( 2 != 2 ) |
| 18 | with context: |
| 19 | current iteration of loop: |
| 20 | i := 1 |
| 21 | |
| 22 | logging.cpp(0) ERROR! |
| 23 | CHECK( vec[i] != (1 << i) ) |
| 24 | with expansion: |
| 25 | CHECK( 4 != 4 ) |
| 26 | with context: |
| 27 | current iteration of loop: |
| 28 | i := 2 |
| 29 | |
| 30 | logging.cpp(0) ERROR! |
| 31 | CHECK( vec[i] != (1 << i) ) |
| 32 | with expansion: |
| 33 | CHECK( 8 != 8 ) |
| 34 | with context: |
| 35 | current iteration of loop: |
| 36 | i := 3 |
| 37 | |
| 38 | logging.cpp(0) ERROR! |
| 39 | CHECK( vec[i] != (1 << i) ) |
| 40 | with expansion: |
| 41 | CHECK( 16 != 16 ) |
| 42 | with context: |
| 43 | current iteration of loop: |
| 44 | i := 4 |
| 45 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 46 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 47 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 48 | TEST CASE: a test case that will end from an exception |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 49 | |
| 50 | logging.cpp(0) ERROR! |
onqtam | 321f270 | 2017-05-01 19:14:58 +0300 | [diff] [blame^] | 51 | forcing the many captures (including those on the heap) to be stringified |
| 52 | with context: |
| 53 | lots of captures - some on heap: 42 42 42; |
| 54 | |
| 55 | logging.cpp(0) ERROR! |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 56 | CHECK( some_var == 666 ) |
| 57 | with expansion: |
| 58 | CHECK( 42 == 666 ) |
| 59 | with context: |
| 60 | someTests() returned: 42 |
| 61 | this should be printed if an exception is thrown even if no assert has failed: 42 |
| 62 | in a nested scope this should be printed as well: 42 |
| 63 | why is this not 666 ?! |
| 64 | |
| 65 | TEST CASE FAILED! |
| 66 | threw exception: |
| 67 | 0 |
| 68 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 69 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 70 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 71 | TEST CASE: third party asserts can report failures to doctest |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 72 | |
| 73 | logging.cpp(0) ERROR! |
| 74 | MY_ASSERT(false) |
| 75 | |
| 76 | logging.cpp(0) FATAL ERROR! |
| 77 | MY_ASSERT_FATAL(false) |
| 78 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 79 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 80 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 81 | TEST CASE: explicit failures 1 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 82 | |
| 83 | logging.cpp(0) ERROR! |
| 84 | this should not end the test case, but mark it as failing |
| 85 | |
onqtam | 378d670 | 2017-04-19 11:30:03 +0300 | [diff] [blame] | 86 | logging.cpp(0) MESSAGE! |
| 87 | reached! |
| 88 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 89 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 90 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame] | 91 | TEST CASE: explicit failures 2 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 92 | |
| 93 | logging.cpp(0) FATAL ERROR! |
| 94 | fail the test case and also end it |
| 95 | |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 96 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 97 | [doctest] test cases: 5 | 0 passed | 5 failed | |
| 98 | [doctest] assertions: 6 | 0 passed | 6 failed | |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 99 | Program code. |