GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/util/test_lua_script_executor.cpp
Date: 2025-10-24 14:26:41
Coverage Exec Excl Total
Lines: 100.0% 25 0 25
Functions: 100.0% 9 0 9
Branches: 27.3% 6 0 22
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 12/15/24.
3 //
4
5 #include "pch.h"
6
7 #include "test_lua_script_executor.h"
8
9 #include "rusefi_lua.h"
10
11 185 TestLuaScriptExecutor& TestLuaScriptExecutor::getInstance() {
12 185 return instance;
13 }
14
15 namespace {
16 constexpr const char* const LUA_TRUE = "true";
17 constexpr const char* const LUA_FALSE = "false";
18
19 177 const char* toLuaBoolean(const bool value) {
20
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 88 times.
177 return (value ? LUA_TRUE : LUA_FALSE);
21 }
22 }
23
24 58 void TestLuaScriptExecutor::setClutchDownState(const bool state) {
25 58 executeFormattedLuaScript("setClutchDownState(%s);", toLuaBoolean(state));
26 58 }
27
28 58 void TestLuaScriptExecutor::setClutchUpState(const bool state) {
29 58 executeFormattedLuaScript("setClutchUpState(%s);", toLuaBoolean(state));
30 58 }
31
32 61 void TestLuaScriptExecutor::setTorqueReductionState(const bool state) {
33 61 executeFormattedLuaScript("setTorqueReductionState(%s);", toLuaBoolean(state));
34 61 }
35
36 3 void TestLuaScriptExecutor::setSparkSkipRatio(const float sparkSkipRatio) {
37 3 executeFormattedLuaScript("setSparkSkipRatio(%f);", sparkSkipRatio);
38 3 }
39
40 3 void TestLuaScriptExecutor::setSparkHardSkipRatio(const float sparkSkipRatio) {
41 3 executeFormattedLuaScript("setSparkHardSkipRatio(%f);", sparkSkipRatio);
42 3 }
43
44 2 void TestLuaScriptExecutor::setFuelAdd(const float fuelAdd) {
45 2 executeFormattedLuaScript("setFuelAdd(%f);", fuelAdd);
46 2 }
47
48 185 void TestLuaScriptExecutor::executeLuaScript(const char* luaScript) {
49
4/20
✓ Branch 3 taken 185 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 185 times.
✓ Branch 8 taken 185 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 185 times.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 41 not taken.
✗ Branch 46 not taken.
✗ Branch 49 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 62 not taken.
✗ Branch 67 not taken.
✗ Branch 70 not taken.
185 EXPECT_NO_THROW(testLuaExecString(luaScript));
50 185 }
51
52 TestLuaScriptExecutor TestLuaScriptExecutor::instance;
53