GCC Code Coverage Report


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

Line Branch Exec Source
1 #include "sub_message_parser.h"
2
3
4 ✗ std::string sub_message_parser::parse_air_quality_pm2_5(const std::vector<uint8_t> &payload)
5 {
6 ✗ if(payload.size() != 4) {
7 ✗ std::cerr << "Warning: Air quality PM2_5 found that isn't 4 bytes long." << std::endl;
8 ✗ return ERROR_VALUE;
9 }
10
11 float pm2_5;
12 ✗ std::copy(reinterpret_cast<const char*>(&payload[0]),
13 ✗ reinterpret_cast<const char*>(&payload[4]),
14 reinterpret_cast<char*>(&pm2_5));
15
16 ✗ if(pm2_5 < 0){
17 ✗ std::cerr << "Warning: Air quality PM2_5 found that has negative values." << std::endl;
18 ✗ return ERROR_VALUE;
19 }
20
21 // Convert the raw humidity value to a string
22 ✗ std::ostringstream oss;
23 ✗ oss << pm2_5;
24
25 ✗ return oss.str();
26 }
27