GCC Code Coverage Report


.
File: main.cpp
Date: 0000-00-00 00:00:00
Lines:
18/20
90.0%
Functions:
6/6
100.0%
Branches:
7/14
50.0%
Calls:
9/13
69.2%

Line Branch Call Exec Source Block IDs
1 #include <stdexcept>
2
3 3 int function_that_may_throw(bool die) {
4
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (die) {
5
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
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/1
✓ Call 0 invoked.
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 times.
1/1
✓ Call 0 invoked.
1 function_that_may_throw(argc == 1);
29
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1/1
✓ Call 2 invoked.
1 } catch (std::exception&) {
30
1/1
✓ Call 0 invoked.
1 die_again = false;
31 }
32
33 // GCOV_EXCL_START
34 RAII raii(die_again);
35 // GCOV_EXCL_STOP
36
37 try {
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1/1
✓ Call 0 invoked.
1 raii.method_that_may_throw();
39
0/1
✗ Call 2 not invoked.
} catch (std::exception&) {
40
0/1
✗ Call 0 not invoked.
return 1;
41 }
42
43
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1/1
✓ Call 0 invoked.
1 function_that_may_throw(argc != 1);
44
45 1 return 0;
46 }
47
48
49 1 int main(int argc, char* argv[]) {
50
1/1
✓ Call 0 invoked.
1 return function_with_catchers(argc);
51 }
52