GCC Code Coverage Report


Directory: ./
File: firmware/controllers/sensors/converters/linear_func.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 15 0 15
Functions: 100.0% 2 0 2
Branches: 100.0% 8 0 8
Decisions: 100.0% 4 - 4

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #include "linear_func.h"
4
5 43 void LinearFunc::configure(float in1, float out1, float in2, float out2, float minOutput, float maxOutput) {
6 43 m_minOutput = minOutput;
7 43 m_maxOutput = maxOutput;
8
9 43 in1 = in1 / m_divideInput;
10 43 in2 = in2 / m_divideInput;
11
12 43 m_a = INTERPOLATION_A(in1, out1, in2, out2);
13 43 m_b = out1 - m_a * in1;
14 43 }
15
16 24 SensorResult LinearFunc::convert(float inputValue) const {
17 24 float result = m_a * inputValue + m_b;
18
19 // Bounds checks
20 // Flipped error codes in case of m_a < 0 so that they indicate whether the input
21 // voltage is high/low, instead of the output high/low
22
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 20 times.
2/2
✓ Decision 'true' taken 4 times.
✓ Decision 'false' taken 20 times.
24 if (result > m_maxOutput) {
23
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
4 return m_a > 0 ? UnexpectedCode::High : UnexpectedCode::Low;
24 }
25
26
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
2/2
✓ Decision 'true' taken 4 times.
✓ Decision 'false' taken 16 times.
20 if (result < m_minOutput) {
27
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
4 return m_a > 0 ? UnexpectedCode::Low : UnexpectedCode::High;
28 }
29
30 16 return result;
31 }
32