Line | Branch | Exec | Source |
---|---|---|---|
1 | #include <iostream> | ||
2 | |||
3 | #if defined USE_LAMBDA | ||
4 | # include <algorithm> | ||
5 | # include <array> | ||
6 | # include <functional> | ||
7 | #endif | ||
8 | |||
9 | 1 | int /* GCOVR_EXCL_FUNCTION */ foo(int param) { // GCOVR_EXCL_FUNCTION | |
10 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (param) { |
11 | ✗ | param++; | |
12 | ✗ | } else { | |
13 | 1 | param--; | |
14 | } | ||
15 | |||
16 | 1 | return param; | |
17 | } | ||
18 | |||
19 | 1 | int bar(int param) { // Excluded by CLI option | |
20 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (param) { |
21 | ✗ | param++; | |
22 | ✗ | } else { | |
23 | 1 | param--; | |
24 | } | ||
25 | 1 | 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 | void sort_excluded(void) /* GCOVR_EXCL_FUNCTION */ { LAMBDA_SORT /* THIS is not excluded*/ | ||
45 | LAMBDA_SORT | ||
46 | } | ||
47 | |||
48 | void sort_lambda_excluded(void) | ||
49 | { | ||
50 | LAMBDA_SORT // GCOVR_EXCL_FUNCTION not working because after function definition | ||
51 | |||
52 | std::array<int, 10> arr = { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }; | ||
53 | |||
54 | 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 | } | ||
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 | sort_excluded(); | ||
100 | sort_lambda_excluded(); | ||
101 | sort_excluded_both(); | ||
102 | #endif | ||
103 | 1 | return 0; | |
104 | } | ||
105 |