GCC Code Coverage Report


Directory: ./
File: tasks/liulin_y_matrix_max_column/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 5 5 100.0%
Branches: 39 44 88.6%

Line Branch Exec Source
1 #include "liulin_y_matrix_max_column/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cstddef>
5 #include <limits>
6 #include <vector>
7
8 #include "liulin_y_matrix_max_column/common/include/common.hpp"
9
10 namespace liulin_y_matrix_max_column {
11
12
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
96 LiulinYMatrixMaxColumnSEQ::LiulinYMatrixMaxColumnSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14
15 GetInput().clear();
16
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
96 GetInput().reserve(in.size());
17
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 96 times.
664 for (const auto &row : in) {
18
1/2
✓ Branch 1 taken 568 times.
✗ Branch 2 not taken.
568 GetInput().push_back(row);
19 }
20
21 GetOutput().clear();
22 96 }
23
24
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
96 bool LiulinYMatrixMaxColumnSEQ::ValidationImpl() {
25 const auto &in = GetInput();
26
27
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 80 times.
96 if (in.empty() || in[0].empty()) {
28 return true;
29 }
30
31 const std::size_t cols = in[0].size();
32
33
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 80 times.
624 for (const auto &row : in) {
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
544 if (row.size() != cols) {
35 return true;
36 }
37 }
38
39 80 return GetOutput().empty();
40 }
41
42
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
96 bool LiulinYMatrixMaxColumnSEQ::PreProcessingImpl() {
43 const auto &in = GetInput();
44
45
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 80 times.
96 if (in.empty() || in[0].empty()) {
46 GetOutput().clear();
47 16 return true;
48 }
49
50 const std::size_t cols = in[0].size();
51 80 GetOutput().assign(cols, std::numeric_limits<int>::min());
52 80 return true;
53 }
54
55
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
96 bool LiulinYMatrixMaxColumnSEQ::RunImpl() {
56 const auto &matrix = GetInput();
57 auto &out = GetOutput();
58
59
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 8 times.
96 if (matrix.empty() || matrix[0].empty()) {
60 return true;
61 }
62 80 const int rows = static_cast<int>(matrix.size());
63 80 const int cols = static_cast<int>(matrix[0].size());
64
65
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80 times.
472 for (int col_idx = 0; col_idx < cols; ++col_idx) {
66 392 std::vector<int> column(rows);
67
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 392 times.
4960 for (int row = 0; row < rows; ++row) {
68 4568 column[row] = matrix[row][col_idx];
69 }
70
71 int size = rows;
72
1/2
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
392 std::vector<int> temp = column;
73
74
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 392 times.
1616 while (size > 1) {
75 int new_size = 0;
76
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1224 times.
5976 for (int i = 0; i < size; i += 2) {
77
4/4
✓ Branch 0 taken 4176 times.
✓ Branch 1 taken 576 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 2176 times.
6752 temp[new_size] = (i + 1 < size) ? std::max(temp[i], temp[i + 1]) : temp[i];
78 4752 ++new_size;
79 }
80 size = new_size;
81 }
82
83 392 out[col_idx] = temp[0];
84 }
85
86 return true;
87 }
88
89 96 bool LiulinYMatrixMaxColumnSEQ::PostProcessingImpl() {
90 96 return true;
91 }
92
93 } // namespace liulin_y_matrix_max_column
94