GCC Code Coverage Report


Directory: ./
File: tasks/nikitin_a_vec_sign_rotation/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 22 23 95.7%
Functions: 5 6 83.3%
Branches: 10 14 71.4%

Line Branch Exec Source
1 #include "nikitin_a_vec_sign_rotation/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <vector>
5
6 #include "nikitin_a_vec_sign_rotation/common/include/common.hpp"
7
8 namespace nikitin_a_vec_sign_rotation {
9
10
1/2
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 NikitinAVecSignRotationSEQ::NikitinAVecSignRotationSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 GetInput() = in;
13 116 GetOutput() = 0;
14 116 }
15
16 116 bool NikitinAVecSignRotationSEQ::ValidationImpl() {
17 116 return true;
18 }
19
20 116 bool NikitinAVecSignRotationSEQ::PreProcessingImpl() {
21 116 return true;
22 }
23
24 116 bool NikitinAVecSignRotationSEQ::RunImpl() {
25 int swaps = 0;
26 116 std::vector<double> data = GetInput();
27
28 // Проходим по вектору, ищем различия в знаках
29
2/2
✓ Branch 0 taken 1504 times.
✓ Branch 1 taken 116 times.
1620 for (size_t i = 1; i < data.size(); i++) {
30 2552 if (IsSignChange(data[i - 1], data[i])) {
31 960 swaps++;
32 }
33 }
34
35
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 8 times.
116 GetOutput() = swaps;
36 116 return true;
37 }
38
39 116 bool NikitinAVecSignRotationSEQ::PostProcessingImpl() {
40 116 return true;
41 }
42
43 bool NikitinAVecSignRotationSEQ::IsSignChange(double first_value, double second_value) {
44 // Определяем знак каждого числа
45 1504 const bool first_negative = first_value < 0.0;
46 1504 const bool second_non_negative = second_value >= 0.0;
47 1504 const bool first_non_negative = first_value >= 0.0;
48 1504 const bool second_negative = second_value < 0.0;
49
50 // Сравниваем знаки. true - знаки разные, false - знаки одинаковые
51
4/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✓ Branch 3 taken 456 times.
✓ Branch 4 taken 504 times.
✓ Branch 5 taken 544 times.
1504 return (first_negative && second_non_negative) || (first_non_negative && second_negative);
52 }
53
54 } // namespace nikitin_a_vec_sign_rotation
55