GCC Code Coverage Report


Directory: ./
File: tasks/guseva_crs/common/include/test_reader.hpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 2 2 100.0%
Branches: 13 20 65.0%

Line Branch Exec Source
1 #pragma once
2
3 #include <cstddef>
4 #include <fstream>
5 #include <string>
6 #include <tuple>
7 #include <vector>
8
9 #include "common.hpp"
10
11 namespace guseva_crs {
12
13 468 inline CRS ReadCRSFromFile(std::ifstream &file) {
14 468 std::size_t nz = 0;
15 468 std::size_t nrows = 0;
16 468 std::size_t ncols = 0;
17 468 std::vector<double> values;
18 468 std::vector<std::size_t> cols;
19 468 std::vector<std::size_t> row_ptrs;
20
1/2
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
468 file >> nz >> nrows >> ncols;
21 468 double tmp = {};
22
2/2
✓ Branch 0 taken 26962 times.
✓ Branch 1 taken 468 times.
27430 for (std::size_t i = 0; i < nz; i++) {
23 file >> tmp;
24 values.push_back(tmp);
25 }
26 468 std::size_t second_tmp = 0;
27
2/2
✓ Branch 0 taken 26962 times.
✓ Branch 1 taken 468 times.
27430 for (std::size_t i = 0; i < nz; i++) {
28 file >> second_tmp;
29 cols.push_back(second_tmp);
30 }
31
32
2/2
✓ Branch 0 taken 8034 times.
✓ Branch 1 taken 468 times.
8502 for (std::size_t i = 0; i < nrows + 1; i++) {
33 file >> second_tmp;
34 row_ptrs.push_back(second_tmp);
35 }
36
3/6
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 468 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 468 times.
✗ Branch 8 not taken.
936 return CRS(nz, nrows, ncols, values, cols, row_ptrs);
37 }
38
39 156 inline std::tuple<CRS, CRS, CRS> ReadTestFromFile(const std::string &filename) {
40 156 std::ifstream file(filename);
41
3/6
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 156 times.
✗ Branch 8 not taken.
468 return {ReadCRSFromFile(file), ReadCRSFromFile(file), ReadCRSFromFile(file)};
42 156 }
43
44 } // namespace guseva_crs
45