| Line | Branch | Condition | Exec | Source |
|---|---|---|---|---|
| 1 | #include <iostream> | |||
| 2 | ||||
| 3 | #if defined USE_LAMBDA | |||
| 4 | # include <algorithm> | |||
| 5 | # include <array> | |||
| 6 | # include <functional> | |||
| 7 | #endif | |||
| 8 | ||||
| 9 | − | int /* GCOVR_EXCL_FUNCTION */ foo(int param) { // GCOVR_EXCL_FUNCTION | ||
| 10 | − | if (param) { | ||
| 11 | − | param++; | ||
| 12 | } else { | |||
| 13 | − | param--; | ||
| 14 | } | |||
| 15 | ||||
| 16 | − | return param; | ||
| 17 | } | |||
| 18 | ||||
| 19 | − | int bar(int param) { // Excluded by CLI option | ||
| 20 | − | if (param) { | ||
| 21 | − | param++; | ||
| 22 | } else { | |||
| 23 | − | param--; | ||
| 24 | } | |||
| 25 | − | return param; | ||
| 26 | } | |||
| 27 | ||||
| 28 | #if defined USE_LAMBDA | |||
| 29 | #define LAMBDA_SORT / | |||
| 30 | { / | |||
| 31 | std::array<int, 10> arr = { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }; / | |||
| 32 | std::sort( / | |||
| 33 | std::begin(arr), / | |||
| 34 | std::end(arr), / | |||
| 35 | [](int a, int b) { / | |||
| 36 | if (a > b) / | |||
| 37 | return true; / | |||
| 38 | return false; / | |||
| 39 | } / | |||
| 40 | ); / | |||
| 41 | } | |||
| 42 | ||||
| 43 | // Function in line with exclude | |||
| 44 |
2/2✓ Branch 0 (6→7) taken 26 times.
✓ Branch 1 (6→13) taken 16 times.
|
2/2✓ Fully covered.
|
44 | void sort_excluded(void) /* GCOVR_EXCL_FUNCTION */ { LAMBDA_SORT /* THIS is not excluded*/ |
| 45 |
2/2✓ Branch 0 (11→12) taken 26 times.
✓ Branch 1 (11→14) taken 16 times.
|
2/2✓ Fully covered.
|
44 | LAMBDA_SORT |
| 46 | − | } | ||
| 47 | ||||
| 48 | 1 | void sort_lambda_excluded(void) | ||
| 49 | { | |||
| 50 |
3/4✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→13) not taken.
✓ Branch 2 (2→3) taken 25 times.
✓ Branch 3 (2→4) taken 16 times.
|
2/2✓ Fully covered.
|
44 | LAMBDA_SORT // GCOVR_EXCL_FUNCTION not working because after function definition |
| 51 | ||||
| 52 | 1 | std::array<int, 10> arr = { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }; | ||
| 53 | ||||
| 54 |
1/2✓ Branch 0 (11→12) taken 1 times.
✗ Branch 1 (11→14) not taken.
|
2 | std::sort( | |
| 55 | std::begin(arr), | |||
| 56 | std::end(arr), | |||
| 57 | − | [](int a, int b) { // GCOVR_EXCL_FUNCTION | ||
| 58 | − | if (a > b) | ||
| 59 | − | return true; | ||
| 60 | ||||
| 61 | − | return false; | ||
| 62 | } | |||
| 63 | ); | |||
| 64 | 1 | } | ||
| 65 | ||||
| 66 | − | void sort_excluded_both(void) // GCOVR_EXCL_FUNCTION | ||
| 67 | { | |||
| 68 | − | std::array<int, 10> arr = { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }; | ||
| 69 | ||||
| 70 | − | std::sort( | ||
| 71 | std::begin(arr), | |||
| 72 | std::end(arr), | |||
| 73 | − | [](int a, int b) { // GCOVR_EXCL_FUNCTION | ||
| 74 | − | if (a > b) | ||
| 75 | − | return true; | ||
| 76 | ||||
| 77 | − | return false; | ||
| 78 | } | |||
| 79 | ); | |||
| 80 | ||||
| 81 | − | std::sort( | ||
| 82 | std::begin(arr), | |||
| 83 | std::end(arr), | |||
| 84 | − | [](int a, int b) { // Excluded by CLI option | ||
| 85 | − | if (a > b) | ||
| 86 | − | return true; | ||
| 87 | ||||
| 88 | − | return false; | ||
| 89 | } | |||
| 90 | ); | |||
| 91 | − | } | ||
| 92 | #endif | |||
| 93 | ||||
| 94 | ||||
| 95 | 1 | int main(int argc, char* argv[]) { | ||
| 96 | 1 | foo(0); | ||
| 97 | 1 | bar(0); | ||
| 98 | #if defined USE_LAMBDA | |||
| 99 | 1 | sort_excluded(); | ||
| 100 | 1 | sort_lambda_excluded(); | ||
| 101 | 1 | sort_excluded_both(); | ||
| 102 | #endif | |||
| 103 | 1 | return 0; | ||
| 104 | } | |||
| 105 |