GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 6 / 0 / 6
Functions: -% 0 / 1 / 1
Branches: -% 0 / 0 / 0
Decisions: -% 0 / - / 0

unit_tests/tests/util/test_lua_script_executor.h
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 185 void TestLuaScriptExecutor::executeFormattedLuaScript(const char* const luaScriptFormatString, Args... args) {
26 185 char luaScript[256];
27 185 const size_t luaScriptLength = std::snprintf(luaScript, sizeof(luaScript), luaScriptFormatString, args...);
28 185 ASSERT_TRUE(0 <= luaScriptLength) << "Encoding error" << std::endl << luaScriptFormatString;
29 185 ASSERT_TRUE(luaScriptLength < sizeof(luaScript)) << "Insufficient buffer" << std::endl << luaScriptFormatString;
30 185 executeLuaScript(luaScript);
31 }
32