GCC Code Coverage Report


Directory: ./
File: tasks/romanov_m_closest_elem_vec/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 5 5 100.0%
Branches: 8 10 80.0%

Line Branch Exec Source
1 #include "romanov_m_closest_elem_vec/seq/include/ops_seq.hpp"
2
3 #include <cmath>
4 #include <cstddef>
5 #include <tuple>
6 #include <vector>
7
8 #include "romanov_m_closest_elem_vec/common/include/common.hpp"
9
10 namespace romanov_m_closest_elem_vec {
11
12
1/2
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
114 RomanovMClosestElemVecSEQ::RomanovMClosestElemVecSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14
1/2
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
114 GetInput() = in;
15 GetOutput() = std::make_tuple(-1, -1);
16 ;
17 114 }
18
19 114 bool RomanovMClosestElemVecSEQ::ValidationImpl() {
20 114 return GetInput().size() >= 2;
21 }
22
23 114 bool RomanovMClosestElemVecSEQ::PreProcessingImpl() {
24 114 return true;
25 }
26
27 114 bool RomanovMClosestElemVecSEQ::RunImpl() {
28 const auto &v = GetInput();
29 const size_t size = v.size();
30
31 114 int min_diff = std::abs(v[1] - v[0]);
32 int min_idx = 0;
33
34
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 114 times.
3314 for (size_t i = 1; i < size - 1; ++i) {
35
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3120 times.
3200 int current_diff = std::abs(v[i + 1] - v[i]);
36
37
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3120 times.
3200 if (current_diff < min_diff) {
38 min_diff = current_diff;
39 80 min_idx = static_cast<int>(i);
40 }
41 }
42
43 114 GetOutput() = std::make_tuple(min_idx, min_idx + 1);
44 114 return true;
45 }
46
47 114 bool RomanovMClosestElemVecSEQ::PostProcessingImpl() {
48 114 return true;
49 }
50
51 } // namespace romanov_m_closest_elem_vec
52