GCC Code Coverage Report


Directory: ./
File: tasks/votincev_d_alternating_values/seq/src/ops_seq.cpp
Date: 2025-12-11 15:42:14
Exec Total Coverage
Lines: 18 19 94.7%
Functions: 5 6 83.3%
Branches: 14 24 58.3%

Line Branch Exec Source
1 #include "votincev_d_alternating_values/seq/include/ops_seq.hpp"
2
3 #include <cstddef> // для size_t
4 #include <vector>
5
6 #include "votincev_d_alternating_values/common/include/common.hpp"
7
8 namespace votincev_d_alternating_values {
9
10
1/2
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
80 VotincevDAlternatingValuesSEQ::VotincevDAlternatingValuesSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
80 GetInput() = in;
13 80 GetOutput() = 0;
14 80 }
15
16 80 bool VotincevDAlternatingValuesSEQ::ValidationImpl() {
17 80 return true;
18 }
19
20 80 bool VotincevDAlternatingValuesSEQ::PreProcessingImpl() {
21 80 return true;
22 }
23
24 80 bool VotincevDAlternatingValuesSEQ::RunImpl() {
25 int all_swaps = 0;
26 80 std::vector<double> vect_data = GetInput();
27
2/2
✓ Branch 0 taken 39000 times.
✓ Branch 1 taken 80 times.
39080 for (size_t i = 1; i < vect_data.size(); i++) {
28 39000 if (IsSignChange(vect_data[i - 1], vect_data[i])) {
29 19912 all_swaps++;
30 }
31 }
32
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 8 times.
80 GetOutput() = all_swaps;
33 80 return true;
34 }
35
36 // вспомогательная, if с такими условиями выглядит страшно
37 bool VotincevDAlternatingValuesSEQ::IsSignChange(const double &a, const double &b) {
38
8/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 19552 times.
✓ Branch 9 taken 19448 times.
✓ Branch 10 taken 9592 times.
✓ Branch 11 taken 9960 times.
✓ Branch 12 taken 19448 times.
✓ Branch 13 taken 9592 times.
✓ Branch 14 taken 9952 times.
✓ Branch 15 taken 9496 times.
39000 return ((a < 0 && b >= 0) || (a >= 0 && b < 0));
39 }
40
41 80 bool VotincevDAlternatingValuesSEQ::PostProcessingImpl() {
42 80 return true;
43 }
44
45 } // namespace votincev_d_alternating_values
46