GCC Code Coverage Report


Directory: ./
File: tasks/sakharov_a_cannon_algorithm/common/include/common.hpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 1 1 100.0%
Branches: 8 18 44.4%

Line Branch Exec Source
1 #pragma once
2
3 #include <cstddef>
4 #include <string>
5 #include <tuple>
6 #include <vector>
7
8 #include "task/include/task.hpp"
9
10 namespace sakharov_a_cannon_algorithm {
11
12 1792 struct MatrixInput {
13 int rows_a = 0;
14 int cols_a = 0;
15 int rows_b = 0;
16 int cols_b = 0;
17 std::vector<double> a;
18 std::vector<double> b;
19 };
20
21 using InType = MatrixInput;
22 using OutType = std::vector<double>;
23 using TestType = std::tuple<MatrixInput, OutType, std::string>;
24 using BaseTask = ppc::task::Task<InType, OutType>;
25
26 inline std::size_t Idx(int cols, int row, int col) {
27
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
7622 return (static_cast<std::size_t>(row) * static_cast<std::size_t>(cols)) + static_cast<std::size_t>(col);
28 }
29
30 80 inline bool IsValidInput(const MatrixInput &input) {
31
5/10
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80 times.
80 if (input.rows_a <= 0 || input.cols_a <= 0 || input.rows_b <= 0 || input.cols_b <= 0 ||
32 input.cols_a != input.rows_b) {
33 return false;
34 }
35 80 auto expected_a = static_cast<std::size_t>(input.rows_a) * static_cast<std::size_t>(input.cols_a);
36
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 auto expected_b = static_cast<std::size_t>(input.rows_b) * static_cast<std::size_t>(input.cols_b);
37
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
80 return input.a.size() == expected_a && input.b.size() == expected_b;
38 }
39
40 } // namespace sakharov_a_cannon_algorithm
41