GCC Code Coverage Report


Directory: src/
File: src/message_parser/sub_message_parser/parse_temperature.cpp
Date: 2026-10-30 09:10:40
Exec Total Coverage
Lines: 0 13 0.0%
Branches: 0 22 0.0%

Line Branch Exec Source
1 #include "sub_message_parser.h"
2
3
4 ✗ std::string sub_message_parser::parse_temperature(const std::vector<uint8_t> &payload)
5 {
6 ✗ if(payload.size() != 2) {
7 ✗ std::cerr << "Warning: Temperature found that isn't 2 bytes long." << std::endl;
8 ✗ return ERROR_VALUE;
9 }
10
11 ✗ const uint8_t temperature_whole = payload[0];
12 ✗ const uint8_t temperature_fractional = payload[1];
13
14 ✗ const float temperature = static_cast<float>(temperature_whole) + static_cast<float>(temperature_fractional)/100;
15
16 ✗ if(temperature_fractional > 100){
17 ✗ std::cerr << "Warning: Temperature fractional can't be above 100." << std::endl;
18 ✗ return ERROR_VALUE;
19 }
20
21 // Convert the raw humidity value to a string
22 ✗ std::ostringstream oss;
23 ✗ oss << temperature;
24
25 ✗ return oss.str();
26 }
27