./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
0 / 18
0.0%
Branches:
0 / 30
0.0%
Functions:
0 / 2
0.0%

libs/base/src/eu/base/memorychunk.cc
Line Branch Exec Source
1 #include "eu/base/memorychunk.h"
2
3 #include <fstream>
4
5 namespace eu
6 {
7
8 ✗ MemoryChunkData::operator MemoryChunk() const
9 {
10 ✗ return {.bytes = bytes.data(), .size = bytes.size() };
11 }
12
13
14
15 ✗ MemoryChunkData chunk_from_file(const std::string& full_path)
16 {
17
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 42 not taken.
✗ std::ifstream is(full_path, std::ifstream::binary);
18
0/4
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 40 not taken.
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 10 not taken.
✗ if(!is)
19 {
20
0/6
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 40 not taken.
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 32 not taken.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 30 not taken.
✗ LOG_ERR("Failed to read real file {}", full_path);
21 ✗ return {};
22 }
23
24
0/2
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 40 not taken.
✗ is.seekg(0, std::ifstream::end);
25
0/2
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 40 not taken.
✗ const auto length = is.tellg();
26
0/2
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 40 not taken.
✗ is.seekg(0, std::ifstream::beg);
27
28
0/2
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 20 not taken.
✗ if(length <= 0)
29 {
30
0/6
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 40 not taken.
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 36 not taken.
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 34 not taken.
✗ LOG_ERR("File empty: {}", full_path);
31 ✗ return {};
32 }
33
34 ✗ MemoryChunkData memory;
35
0/2
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 38 not taken.
✗ memory.bytes.resize(length);
36 is.read
37
0/2
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 38 not taken.
✗ (
38 memory.bytes.data(),
39 length
40 );
41
42 ✗ return memory;
43 ✗ }
44
45 }
46