mirror of https://github.com/rusefi/rusefi-1.git
switch to array'd version of asserts (#2158)
This commit is contained in:
parent
98644b680f
commit
1df887bc8c
|
@ -10,6 +10,8 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.rusefi.IoUtil.getEnableCommand;
|
||||
import static com.rusefi.TestingUtils.*;
|
||||
import static com.rusefi.config.generated.Fields.*;
|
||||
|
@ -39,12 +41,16 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
EngineChart chart = nextChart();
|
||||
|
||||
// Wasted spark should fire cylinders 1/3...
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
||||
assertWaveNotNull(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.SPARK_3
|
||||
);
|
||||
|
||||
// ...but not cylinders 2/4
|
||||
assertWaveNull(chart, EngineChart.SPARK_2);
|
||||
assertWaveNull(chart, EngineChart.SPARK_4);
|
||||
assertWaveNull(chart,
|
||||
EngineChart.SPARK_2,
|
||||
EngineChart.SPARK_4
|
||||
);
|
||||
}
|
||||
|
||||
// Now switch to sequential mode
|
||||
|
@ -55,10 +61,12 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
EngineChart chart = nextChart();
|
||||
|
||||
// All 4 cylinders should be firing
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_2);
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_4);
|
||||
assertWaveNotNull(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.SPARK_2,
|
||||
EngineChart.SPARK_3,
|
||||
EngineChart.SPARK_4
|
||||
);
|
||||
}
|
||||
|
||||
// Now switch to "one coil" mode
|
||||
|
@ -72,9 +80,11 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
|
||||
// And no others
|
||||
assertWaveNull(chart, EngineChart.SPARK_2);
|
||||
assertWaveNull(chart, EngineChart.SPARK_3);
|
||||
assertWaveNull(chart, EngineChart.SPARK_4);
|
||||
assertWaveNull(chart,
|
||||
EngineChart.SPARK_2,
|
||||
EngineChart.SPARK_3,
|
||||
EngineChart.SPARK_4
|
||||
);
|
||||
}
|
||||
|
||||
// Now switch BACK to wasted mode
|
||||
|
@ -85,12 +95,16 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
EngineChart chart = nextChart();
|
||||
|
||||
// Wasted spark should fire cylinders 1/3...
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
||||
assertWaveNotNull(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.SPARK_3
|
||||
);
|
||||
|
||||
// ...but not cylinders 2/4
|
||||
assertWaveNull(chart, EngineChart.SPARK_2);
|
||||
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
||||
assertWaveNull(chart,
|
||||
EngineChart.SPARK_2,
|
||||
EngineChart.SPARK_4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,8 +125,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
// Check that neither ignition nor injection is cut
|
||||
EngineChart chart = nextChart();
|
||||
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
assertWaveNotNull(chart, EngineChart.INJECTOR_1);
|
||||
assertWaveNotNull(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.INJECTOR_1
|
||||
);
|
||||
}
|
||||
|
||||
// Now go above the hard limiter
|
||||
|
@ -124,8 +140,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
|
||||
// These channels are allowed to have falling edges - aka closing injectors and firing coils
|
||||
// but not allowed to have rising edges - aka opening injectors and charging coils
|
||||
assertWaveNoRises(chart, EngineChart.SPARK_1);
|
||||
assertWaveNoRises(chart, EngineChart.INJECTOR_1);
|
||||
assertWaveNoRises(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.INJECTOR_1
|
||||
);
|
||||
}
|
||||
|
||||
// Check that it recovers when we go back under the limit
|
||||
|
@ -135,8 +153,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
// Check that neither ignition nor injection is cut
|
||||
EngineChart chart = nextChart();
|
||||
|
||||
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||
assertWaveNotNull(chart, EngineChart.INJECTOR_1);
|
||||
assertWaveNotNull(chart,
|
||||
EngineChart.SPARK_1,
|
||||
EngineChart.INJECTOR_1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,6 +461,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
assertWaveNull("", chart, key);
|
||||
}
|
||||
|
||||
private static void assertWaveNull(EngineChart chart, String... keys) {
|
||||
Arrays.stream(keys).peek(k -> assertWaveNull(chart, k));
|
||||
}
|
||||
|
||||
private static void assertWaveNull(String msg, EngineChart chart, String key) {
|
||||
assertNull(msg + "chart for " + key, chart.get(key));
|
||||
}
|
||||
|
@ -453,6 +477,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
assertTrue(msg, chart.get(key) != null);
|
||||
}
|
||||
|
||||
private static void assertWaveNotNull(EngineChart chart, String... keys) {
|
||||
Arrays.stream(keys).peek(k -> assertWaveNotNull(chart, k));
|
||||
}
|
||||
|
||||
private static void assertWaveNoRises(EngineChart chart, String key) {
|
||||
StringBuilder events = chart.get(key);
|
||||
|
||||
|
@ -465,6 +493,10 @@ public class FunctionalTest extends RusefiTestBase {
|
|||
assertFalse(events.toString().contains("u"));
|
||||
}
|
||||
|
||||
private static void assertWaveNoRises(EngineChart chart, String... keys) {
|
||||
Arrays.stream(keys).peek(k -> assertWaveNoRises(chart, k));
|
||||
}
|
||||
|
||||
private EngineChart nextChart() {
|
||||
return TestingUtils.nextChart(ecu.commandQueue);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue