GCC Code Coverage Report


Directory: ./
File: tasks/zagryadskov_m_max_by_column/seq/src/max_by_column.cpp
Date: 2026-01-09 01:27:18
Exec Total Coverage
Lines: 21 21 100.0%
Functions: 5 5 100.0%
Branches: 18 32 56.2%

Line Branch Exec Source
1 #include "zagryadskov_m_max_by_column/seq/include/max_by_column.hpp"
2
3 #include <cstddef>
4 #include <limits>
5 #include <type_traits>
6
7 #include "zagryadskov_m_max_by_column/common/include/common.hpp"
8
9 namespace zagryadskov_m_max_by_column {
10
11
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 ZagryadskovMMaxByColumnSEQ::ZagryadskovMMaxByColumnSEQ(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 GetInput() = in;
14 16 }
15
16
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 bool ZagryadskovMMaxByColumnSEQ::ValidationImpl() {
17 16 bool if_dividable = std::get<1>(GetInput()).size() % std::get<0>(GetInput()) == 0;
18
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
16 return (std::get<0>(GetInput()) > 0) && (!std::get<1>(GetInput()).empty()) && (GetOutput().empty()) && if_dividable;
19 }
20
21
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 bool ZagryadskovMMaxByColumnSEQ::PreProcessingImpl() {
22 16 bool if_dividable = std::get<1>(GetInput()).size() % std::get<0>(GetInput()) == 0;
23
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 return (std::get<0>(GetInput()) > 0) && (!std::get<1>(GetInput()).empty()) && if_dividable;
24 }
25
26
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 bool ZagryadskovMMaxByColumnSEQ::RunImpl() {
27 16 bool if_dividable = std::get<1>(GetInput()).size() % std::get<0>(GetInput()) == 0;
28
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 if ((std::get<0>(GetInput()) == 0) || (std::get<1>(GetInput()).empty()) || !if_dividable) {
29 return false;
30 }
31
32 const auto &n = std::get<0>(GetInput());
33 const auto &mat = std::get<1>(GetInput());
34 16 size_t m = mat.size() / n;
35 OutType &res = GetOutput();
36 OutType rows;
37 using T = std::decay_t<decltype(*mat.begin())>;
38
39 size_t j = 0;
40 size_t i = 0;
41 16 res.resize(n, std::numeric_limits<T>::lowest());
42 T tmp = std::numeric_limits<T>::lowest();
43 bool tmp_flag = false;
44
2/2
✓ Branch 0 taken 32808 times.
✓ Branch 1 taken 16 times.
32824 for (j = 0; j < n; ++j) {
45
2/2
✓ Branch 0 taken 67109264 times.
✓ Branch 1 taken 32808 times.
67142072 for (i = 0; i < m; ++i) {
46 67109264 tmp = mat[(j * m) + i];
47 67109264 tmp_flag = tmp > res[j];
48 67109264 res[j] = (static_cast<T>(tmp_flag) * tmp) + (static_cast<T>(!tmp_flag) * res[j]);
49 }
50 }
51
52 16 return !GetOutput().empty();
53 }
54
55 16 bool ZagryadskovMMaxByColumnSEQ::PostProcessingImpl() {
56 16 return !GetOutput().empty();
57 }
58
59 } // namespace zagryadskov_m_max_by_column
60