| Line | Branch | Exec | Source | Block IDs |
|---|---|---|---|---|
| 1 | #include <stdexcept> | |||
| 2 | ||||
| 3 | 3 | int function_that_may_throw(bool die) { | ||
| 4 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
3 | if (die) { | |
| 5 |
2/4✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
1 | throw std::runtime_error("the error"); | |
| 6 | } else { | |||
| 7 | 2 | return 42; | ||
| 8 | } | |||
| 9 | } | |||
| 10 | ||||
| 11 | struct RAII { | |||
| 12 | bool die; | |||
| 13 | ||||
| 14 | RAII(bool); | |||
| 15 | ~RAII(); | |||
| 16 | 1 | int method_that_may_throw() const { | ||
| 17 | 1 | return function_that_may_throw(die); | ||
| 18 | } | |||
| 19 | }; | |||
| 20 | ||||
| 21 | 1 | RAII::RAII(bool die) :die(die) {} | ||
| 22 | 1 | RAII::~RAII() {} | ||
| 23 | ||||
| 24 | 1 | int function_with_catchers(int argc) { | ||
| 25 | 1 | bool die_again = true; | ||
| 26 | ||||
| 27 | try { | |||
| 28 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | function_that_may_throw(argc == 1); | |
| 29 |
0/2✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | } catch (std::exception&) { | |
| 30 | 1 | die_again = false; | ||
| 31 | } | |||
| 32 | ||||
| 33 |
3/6✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
|
3 | RAII raii(die_again); | |
| 34 | ||||
| 35 | try { | |||
| 36 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | raii.method_that_may_throw(); | |
| 37 | ✗ | } catch (std::exception&) { | ||
| 38 | ✗ | return 1; | ||
| 39 | } | |||
| 40 | ||||
| 41 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | function_that_may_throw(argc != 1); | |
| 42 | ||||
| 43 | 1 | return 0; | ||
| 44 | } | |||
| 45 | ||||
| 46 | ||||
| 47 | 1 | int main(int argc, char* argv[]) { | ||
| 48 | 1 | return function_with_catchers(argc); | ||
| 49 | } | |||
| 50 |