2021-11-05 13:08:48 -07:00
|
|
|
/*
|
|
|
|
* test_lua_with_engine.cpp
|
|
|
|
*
|
|
|
|
* Created on: Nov 5, 2021
|
|
|
|
* Author: rusefi
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pch.h"
|
2022-07-14 04:52:58 -07:00
|
|
|
#include "script_impl.h"
|
2021-11-05 13:08:48 -07:00
|
|
|
#include "rusefi_lua.h"
|
|
|
|
|
|
|
|
static const char* curveTestScript = R"(
|
|
|
|
|
|
|
|
function testFunc()
|
|
|
|
index = findCurveIndex("HELLO")
|
|
|
|
return curve(index, 40)
|
|
|
|
end
|
|
|
|
|
|
|
|
)";
|
|
|
|
|
|
|
|
TEST(LuaHooks, TestCurve) {
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
2021-11-05 13:08:48 -07:00
|
|
|
|
|
|
|
strcpy(engineConfiguration->scriptCurveName[3], "hello");
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve4, 500, 600, 1);
|
2021-11-05 13:08:48 -07:00
|
|
|
|
2022-08-28 06:43:21 -07:00
|
|
|
auto index = getCurveIndexByName("helLO");
|
|
|
|
ASSERT_EQ(index.value_or(-1), 3);
|
2021-11-05 13:08:48 -07:00
|
|
|
|
|
|
|
EXPECT_EQ(testLuaReturnsNumberOrNil(curveTestScript).value_or(0), 540);
|
|
|
|
}
|