| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | #include "rusefi_lua.h" | |||
| 3 | ||||
| 4 | ||||
| 5 | 4 | TEST(LuaDebounce, DebounceSignal) { | ||
| 6 | ||||
| 7 | static const char code[] = R"( | |||
| 8 | button = SignalDebounce.new(0.1) | |||
| 9 | ||||
| 10 | function delay(seconds) | |||
| 11 | advanceTimeUs(seconds*1000000) | |||
| 12 | end | |||
| 13 | ||||
| 14 | function testFunc() | |||
| 15 | -- fast changes should be ignored | |||
| 16 | local startVal = button:get() | |||
| 17 | for i=0,10 do | |||
| 18 | button:set(i % 2 == 1) | |||
| 19 | if button:get() ~= startVal then | |||
| 20 | return 1 | |||
| 21 | end | |||
| 22 | delay(0.05) | |||
| 23 | end | |||
| 24 | ||||
| 25 | -- slow changes - should be ok | |||
| 26 | button:set(true) | |||
| 27 | delay(0.15) | |||
| 28 | button:set(true) | |||
| 29 | if not button:get() then | |||
| 30 | return 2 | |||
| 31 | end | |||
| 32 | ||||
| 33 | -- release button | |||
| 34 | button:set(false) | |||
| 35 | delay(0.15) | |||
| 36 | button:set(false) | |||
| 37 | if button:get() then | |||
| 38 | return 3 | |||
| 39 | end | |||
| 40 | ||||
| 41 | return 0 | |||
| 42 | end | |||
| 43 | ||||
| 44 | )"; | |||
| 45 | ||||
| 46 |
3/7✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(testLuaReturnsInteger(code), 0); | |
| 47 | 1 | } | ||
| 48 |