GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 62.5% 15 / 0 / 24
Functions: 100.0% 3 / 0 / 3
Branches: 75.0% 15 / 0 / 20
Decisions: 75.0% 12 / - / 16

firmware/controllers/core/state_sequence.cpp
Line Branch Decision Exec Source
1 /**
2 * @file state_sequence.cpp
3 *
4 * @date May 18, 2014
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8 #include "pch.h"
9 #include "state_sequence.h"
10 #include "trigger_structure.h"
11
12 1013 void MultiChannelStateSequence::checkSwitchTimes(const float scale) const {
13
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1013 times.
1013 efiAssertVoid(ObdCode::CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty");
14
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1013 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 1013 times.
1013 if (getSwitchTime(phaseCount - 1) != 1) {
15 #if EFI_UNIT_TEST
16 for (int index = 0;index < phaseCount;index ++) {
17 printf("switch time index=%d angle=%f\n", index, getSwitchTime(index));
18 }
19 #endif // EFI_UNIT_TEST
20
21 firmwareError(ObdCode::CUSTOM_ERR_WAVE_1, "[count=%d] last switch time has to be 1/%f not %.2f/%f",
22 phaseCount,
23 scale, getSwitchTime(phaseCount - 1),
24 scale * getSwitchTime(phaseCount - 1));
25 return;
26 }
27
2/2
✓ Branch 0 taken 14013 times.
✓ Branch 1 taken 1013 times.
2/2
✓ Decision 'true' taken 14013 times.
✓ Decision 'false' taken 1013 times.
15026 for (int i = 0; i < phaseCount - 1; i++) {
28
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 14013 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 14013 times.
14013 if (getSwitchTime(i) >= getSwitchTime(i + 1)) {
29 firmwareError(ObdCode::CUSTOM_ERR_WAVE_2, "invalid switchTimes @%d: %.2f/%.2f",
30 i, getSwitchTime(i), getSwitchTime(i + 1));
31 }
32 }
33 }
34
35 14126 int MultiChannelStateSequence::findInsertionAngle(const float angle) const {
36
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 1 time.
2/2
✓ Decision 'true' taken 14144 times.
✓ Decision 'false' taken 1 time.
14145 for (int i = phaseCount - 1; i >= 0; i--) {
37
2/2
✓ Branch 1 taken 14125 times.
✓ Branch 2 taken 19 times.
2/2
✓ Decision 'true' taken 14125 times.
✓ Decision 'false' taken 19 times.
14144 if (angle > getSwitchTime(i))
38 14125 return i + 1;
39 }
40 1 return 0;
41 }
42
43 14127 expected<int> MultiChannelStateSequence::findAngleMatch(const float angle) const {
44
2/2
✓ Branch 1 taken 487778 times.
✓ Branch 2 taken 14125 times.
2/2
✓ Decision 'true' taken 487778 times.
✓ Decision 'false' taken 14125 times.
501903 for (int i = 0; i < phaseCount; i++) {
45
4/4
✓ Branch 1 taken 487778 times.
✓ Branch 4 taken 487778 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 487776 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 487776 times.
487778 if (isSameF(getSwitchTime(i), angle))
46 2 return i;
47 }
48 14125 return unexpected;
49 }
50