GCC Code Coverage Report


Directory: ./
File: tasks/urin_o_max_val_in_col_of_mat/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 20 23 87.0%
Functions: 5 5 100.0%
Branches: 14 24 58.3%

Line Branch Exec Source
1 #include "urin_o_max_val_in_col_of_mat/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cstddef>
5 #include <vector>
6 // #include "urin_o_max_val_in_col_of_mat/common/include/common.hpp"
7 /*#include "util/include/util.hpp"*/
8
9 namespace urin_o_max_val_in_col_of_mat {
10
11
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 UrinOMaxValInColOfMatSeq::UrinOMaxValInColOfMatSeq(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 // GetInput() = in;
14
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (!in.empty()) {
15
1/2
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
112 GetInput() = in;
16 } else {
17 GetInput() = InType(); // Explicit empty vector
18 }
19 112 GetOutput() = OutType{};
20 112 }
21
22
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 bool UrinOMaxValInColOfMatSeq::ValidationImpl() {
23 const auto &matrix = GetInput();
24
25
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if (matrix.empty() || matrix[0].empty()) {
26 return false;
27 }
28
29 size_t cols = matrix[0].size();
30 /*for (const auto &row : matrix) {
31 if (row.size() != cols) {
32 return false; // Не прямоугольная матрица
33 }
34 }
35
36 return true;*/
37 // return std::all_of(matrix.begin(), matrix.end(), [cols](const auto &row) { return row.size() == cols; });
38 return std::ranges::all_of(matrix, [cols](const auto &row) { return row.size() == cols; });
39 }
40
41 112 bool UrinOMaxValInColOfMatSeq::PreProcessingImpl() {
42 112 return true;
43 }
44
45
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 bool UrinOMaxValInColOfMatSeq::RunImpl() {
46 const auto &matrix = GetInput();
47
48
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if (matrix.empty() || matrix[0].empty()) {
49 GetOutput() = OutType();
50 return false;
51 }
52
53 size_t rows = matrix.size();
54 size_t cols = matrix[0].size();
55
56 // Инициализируем выходной вектор размером с количество столбцов
57 112 OutType column_maxima(cols);
58
59 // Для каждого столбца находим максимальное значение
60
2/2
✓ Branch 0 taken 5264 times.
✓ Branch 1 taken 112 times.
5376 for (size_t col = 0; col < cols; ++col) {
61 5264 int max_val = matrix[0][col]; // Начинаем с первого элемента столбца
62
63
2/2
✓ Branch 0 taken 2077856 times.
✓ Branch 1 taken 5264 times.
2083120 for (size_t row = 1; row < rows; ++row) {
64 /*if (matrix[row][col] > max_val) {
65 max_val = matrix[row][col];
66 }*/
67 2077856 max_val = std::max(matrix[row][col], max_val);
68 }
69
70 5264 column_maxima[col] = max_val;
71 }
72
73
1/2
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
112 GetOutput() = column_maxima;
74 return true;
75 }
76
77 112 bool UrinOMaxValInColOfMatSeq::PostProcessingImpl() {
78 112 return !GetOutput().empty();
79 }
80
81 } // namespace urin_o_max_val_in_col_of_mat
82