| Directory: | . |
|---|---|
| File: | main.cpp |
| Date: | 2020-09-29 20:04:32 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 16 | 18 | 88.9% |
| Branches: | 8 | 10 | 80.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <iostream> | ||
| 2 | #include <cstring> | ||
| 3 | |||
| 4 | class Bar | ||
| 5 | { | ||
| 6 | public: | ||
| 7 | 1 | Bar() | |
| 8 | 1 | {} | |
| 9 | 1 | virtual ~Bar() | |
| 10 | 1 | {} // possible compiler-generated destruction code - auto-detected and excluded | |
| 11 | |||
| 12 | private: | ||
| 13 | int m_param; | ||
| 14 | }; | ||
| 15 | |||
| 16 | 5 | int foo(int param) { | |
| 17 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
|
5 | if (param == 0 || param == 1) { // 4/4 branches |
| 18 | 2 | return 1; | |
| 19 | } else if (param == 2 || param == 5) { // 3/4 branches, excluded, GCOV_EXCL_LINE | ||
| 20 | 1 | return 0; | |
| 21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } else if (param == 10) { // 1/2 branches |
| 22 | ✗ | return 2; | |
| 23 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } else if (param == 11) { // 1/2 branches |
| 24 | ✗ | return 3; | |
| 25 | } | ||
| 26 | |||
| 27 | // GCOV_EXCL_START | ||
| 28 | if (param == 4) { // 2/2 branches, excluded | ||
| 29 | return 1; | ||
| 30 | } else if (param == 5) { // 1/2 branches, excluded | ||
| 31 | return 0; | ||
| 32 | } | ||
| 33 | // GCOV_EXCL_STOP | ||
| 34 | |||
| 35 | 1 | return 0; | |
| 36 | } | ||
| 37 | |||
| 38 | int bar(int param) { // never called, GCOV_EXCL_START | ||
| 39 | if (param) { | ||
| 40 | return 1; | ||
| 41 | } | ||
| 42 | return 0; | ||
| 43 | } // GCOV_EXCL_STOP | ||
| 44 | |||
| 45 | |||
| 46 | 1 | int main(int argc, char* argv[]) { | |
| 47 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | for (int i = 0; i < 5; i++) { // 2/2 branches |
| 48 | 5 | foo(i); | |
| 49 | } | ||
| 50 | |||
| 51 | try { | ||
| 52 | Bar bar; // LCOV_EXCL_LINE | ||
| 53 | } catch (const std::exception &e) { // LCOV_EXCL_START | ||
| 54 | std::cout << "caught exception"; | ||
| 55 | if (std::strlen(e.what()) > 0) { | ||
| 56 | std::cout << ": " << e.what(); | ||
| 57 | } | ||
| 58 | std::cout << std::endl; | ||
| 59 | } // LCOV_EXCL_STOP | ||
| 60 | |||
| 61 | 1 | return 0; | |
| 62 | 3 | } // compiler-generated destruction code - auto-detected and excluded | |
| 63 | |||
| 64 | // total: 8/10 branches reported | ||
| 65 | |||
| 66 |