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! |
| 51 | CHECK( some_var == 666 ) |
| 52 | with expansion: |
| 53 | CHECK( 42 == 666 ) |
| 54 | with context: |
| 55 | someTests() returned: 42 |
| 56 | this should be printed if an exception is thrown even if no assert has failed: 42 |
| 57 | in a nested scope this should be printed as well: 42 |
| 58 | why is this not 666 ?! |
| 59 | |
| 60 | TEST CASE FAILED! |
| 61 | threw exception: |
| 62 | 0 |
| 63 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 64 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 65 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 66 | TEST CASE: third party asserts can report failures to doctest |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 67 | |
| 68 | logging.cpp(0) ERROR! |
| 69 | MY_ASSERT(false) |
| 70 | |
| 71 | logging.cpp(0) FATAL ERROR! |
| 72 | MY_ASSERT_FATAL(false) |
| 73 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 74 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 75 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 76 | TEST CASE: explicit failures 1 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 77 | |
| 78 | logging.cpp(0) ERROR! |
| 79 | this should not end the test case, but mark it as failing |
| 80 | |
onqtam | 378d670 | 2017-04-19 11:30:03 +0300 | [diff] [blame] | 81 | logging.cpp(0) MESSAGE! |
| 82 | reached! |
| 83 | |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 84 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 85 | logging.cpp(0) |
onqtam | 35c14cd | 2017-04-24 12:54:03 +0300 | [diff] [blame^] | 86 | TEST CASE: explicit failures 2 |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 87 | |
| 88 | logging.cpp(0) FATAL ERROR! |
| 89 | fail the test case and also end it |
| 90 | |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 91 | =============================================================================== |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 92 | [doctest] test cases: 5 | 0 passed | 5 failed | |
| 93 | [doctest] assertions: 6 | 0 passed | 6 failed | |
onqtam | 2c100d6 | 2017-04-16 22:47:28 +0300 | [diff] [blame] | 94 | Program code. |