Line |
Branch |
Decision |
Exec |
Source |
1 |
|
|
|
// |
2 |
|
|
|
// Created by kifir on 12/15/24. |
3 |
|
|
|
// |
4 |
|
|
|
|
5 |
|
|
|
#pragma once |
6 |
|
|
|
|
7 |
|
|
|
class TestLuaScriptExecutor { |
8 |
|
|
|
public: |
9 |
|
|
|
static TestLuaScriptExecutor& getInstance(); |
10 |
|
|
|
|
11 |
|
|
|
void setClutchDownState(bool state); |
12 |
|
|
|
void setClutchUpState(bool state); |
13 |
|
|
|
void setTorqueReductionState(bool state); |
14 |
|
|
|
void setSparkSkipRatio(float sparkSkipRatio); |
15 |
|
|
|
void setSparkHardSkipRatio(float sparkSkipRatio); |
16 |
|
|
|
void setFuelAdd(float fuelAdd); |
17 |
|
|
|
private: |
18 |
|
|
|
template<typename... Args> void executeFormattedLuaScript(const char* luaScriptFormatString, Args... args); |
19 |
|
|
|
void executeLuaScript(const char* luaScript); |
20 |
|
|
|
|
21 |
|
|
|
static TestLuaScriptExecutor instance; |
22 |
|
|
|
}; |
23 |
|
|
|
|
24 |
|
|
|
template<typename... Args> |
25 |
|
|
|
void TestLuaScriptExecutor::executeFormattedLuaScript(const char* const luaScriptFormatString, Args... args) { |
26 |
|
|
|
char luaScript[256]; |
27 |
|
|
|
const size_t luaScriptLength = std::snprintf(luaScript, sizeof(luaScript), luaScriptFormatString, args...); |
28 |
|
|
|
ASSERT_TRUE(0 <= luaScriptLength) << "Encoding error" << std::endl << luaScriptFormatString; |
29 |
|
|
|
ASSERT_TRUE(luaScriptLength < sizeof(luaScript)) << "Insufficient buffer" << std::endl << luaScriptFormatString; |
30 |
|
|
|
executeLuaScript(luaScript); |
31 |
|
|
|
} |
32 |
|
|
|
|