| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /* | |||
| 2 | * test_lua_with_engine.cpp | |||
| 3 | * | |||
| 4 | * Created on: Nov 5, 2021 | |||
| 5 | * Author: rusefi | |||
| 6 | */ | |||
| 7 | ||||
| 8 | #include "pch.h" | |||
| 9 | #include "script_impl.h" | |||
| 10 | #include "rusefi_lua.h" | |||
| 11 | ||||
| 12 | static const char* curveTestScript = R"( | |||
| 13 | ||||
| 14 | function testFunc() | |||
| 15 | index = findCurveIndex("HELLO") | |||
| 16 | return curve(index, 40) | |||
| 17 | end | |||
| 18 | ||||
| 19 | )"; | |||
| 20 | ||||
| 21 | 4 | TEST(LuaHooks, TestCurve) { | ||
| 22 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 23 | ||||
| 24 | 1 | strcpy(engineConfiguration->scriptCurveName[3], "hello"); | ||
| 25 |
1/1✓ Branch 1 taken 1 time.
|
1 | setLinearCurve(config->scriptCurve4, 500, 600, 1); | |
| 26 | ||||
| 27 |
1/1✓ Branch 2 taken 1 time.
|
1 | auto index = getCurveIndexByName("helLO"); | |
| 28 |
3/8✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
|
1 | ASSERT_EQ(index.value_or(-1), 3); | |
| 29 | ||||
| 30 |
3/7✓ Branch 5 taken 1 time.
✓ Branch 9 taken 1 time.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 time.
✗ Branch 19 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(testLuaReturnsNumberOrNil(curveTestScript).value_or(0), 540); | |
| 31 | 1 | } | ||
| 32 |