GCC Code Coverage Report


Directory: ./
File: tasks/guseva_crs/common/include/test_reader.hpp
Date: 2026-04-02 17:12:27
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 288 inline CRS ReadCRSFromFile(std::ifstream &file) {
14 288 std::size_t nz = 0;
15 288 std::size_t nrows = 0;
16 288 std::size_t ncols = 0;
17 288 std::vector<double> values;
18 288 std::vector<std::size_t> cols;
19 288 std::vector<std::size_t> row_ptrs;
20
1/2
✓ Branch 1 taken 288 times.
✗ Branch 2 not taken.
288 file >> nz >> nrows >> ncols;
21 288 double tmp = {};
22
2/2
✓ Branch 0 taken 16592 times.
✓ Branch 1 taken 288 times.
16880 for (std::size_t i = 0; i < nz; i++) {
23 file >> tmp;
24 values.push_back(tmp);
25 }
26 288 std::size_t second_tmp = 0;
27
2/2
✓ Branch 0 taken 16592 times.
✓ Branch 1 taken 288 times.
16880 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 4944 times.
✓ Branch 1 taken 288 times.
5232 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 288 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 288 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 288 times.
✗ Branch 8 not taken.
576 return CRS(nz, nrows, ncols, values, cols, row_ptrs);
37 }
38
39 96 inline std::tuple<CRS, CRS, CRS> ReadTestFromFile(const std::string &filename) {
40 96 std::ifstream file(filename);
41
3/6
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 96 times.
✗ Branch 8 not taken.
288 return {ReadCRSFromFile(file), ReadCRSFromFile(file), ReadCRSFromFile(file)};
42 96 }
43
44 } // namespace guseva_crs
45