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 | 197 | TestLuaScriptExecutor& TestLuaScriptExecutor::getInstance() { | ||
12 | 197 | return instance; | ||
13 | } | |||
14 | ||||
15 | namespace { | |||
16 | constexpr const char* const LUA_TRUE = "true"; | |||
17 | constexpr const char* const LUA_FALSE = "false"; | |||
18 | ||||
19 | 189 | const char* toLuaBoolean(const bool value) { | ||
20 |
2/2✓ Branch 0 taken 95 times.
✓ Branch 1 taken 94 times.
|
189 | return (value ? LUA_TRUE : LUA_FALSE); | |
21 | } | |||
22 | } | |||
23 | ||||
24 | 62 | void TestLuaScriptExecutor::setClutchDownState(const bool state) { | ||
25 | 62 | executeFormattedLuaScript("setClutchDownState(%s);", toLuaBoolean(state)); | ||
26 | 62 | } | ||
27 | ||||
28 | 62 | void TestLuaScriptExecutor::setClutchUpState(const bool state) { | ||
29 | 62 | executeFormattedLuaScript("setClutchUpState(%s);", toLuaBoolean(state)); | ||
30 | 62 | } | ||
31 | ||||
32 | 65 | void TestLuaScriptExecutor::setTorqueReductionState(const bool state) { | ||
33 | 65 | executeFormattedLuaScript("setTorqueReductionState(%s);", toLuaBoolean(state)); | ||
34 | 65 | } | ||
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 | 197 | void TestLuaScriptExecutor::executeLuaScript(const char* luaScript) { | ||
49 |
4/20✓ Branch 3 taken 197 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 197 times.
✓ Branch 8 taken 197 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 197 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.
|
197 | EXPECT_NO_THROW(testLuaExecString(luaScript)); | |
50 | 197 | } | ||
51 | ||||
52 | TestLuaScriptExecutor TestLuaScriptExecutor::instance; | |||
53 |