From f42c6fce58b2ad579e137161e27dc796a41d3f12 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 21 Jun 2021 02:46:11 -0400 Subject: [PATCH] off-topic method rename --- .../f4discovery/CommonFunctionalTest.java | 9 ++++----- .../rusefi/f4discovery/PwmHardwareTest.java | 5 +++-- .../f4discovery/VssHardwareLoopTest.java | 4 ++-- .../rusefi/functional_tests/EcuTestHelper.java | 18 ++++++------------ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/java_console/autotest/src/com/rusefi/f4discovery/CommonFunctionalTest.java b/java_console/autotest/src/com/rusefi/f4discovery/CommonFunctionalTest.java index 0355bf8e43..440834d6a1 100644 --- a/java_console/autotest/src/com/rusefi/f4discovery/CommonFunctionalTest.java +++ b/java_console/autotest/src/com/rusefi/f4discovery/CommonFunctionalTest.java @@ -214,7 +214,7 @@ public class CommonFunctionalTest extends RusefiTestBase { ecu.changeRpm(200); ecu.changeRpm(250); // another approach to artificial delay ecu.changeRpm(200); - EcuTestHelper.assertEquals("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT)); + EcuTestHelper.assertSomewhatClose("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT)); chart = nextChart(); double x = 100; @@ -284,7 +284,7 @@ public class CommonFunctionalTest extends RusefiTestBase { ecu.changeRpm(200); String msg = "ProtegeLX cranking"; chart = nextChart(); - EcuTestHelper.assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1); + EcuTestHelper.assertSomewhatClose("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1); assertWaveNotNull(msg, chart, EngineChart.SPARK_3); assertWaveNotNull(msg, chart, EngineChart.SPARK_1); assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1); @@ -359,9 +359,8 @@ public class CommonFunctionalTest extends RusefiTestBase { sendComplexCommand("set cranking_rpm 500"); ecu.changeRpm(200); - double x; chart = nextChart(); - EcuTestHelper.assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT)); + EcuTestHelper.assertSomewhatClose(12, SensorCentral.getInstance().getValue(Sensor.VBATT)); assertWaveNotNull("aspire default cranking ", chart, EngineChart.SPARK_1); ecu.changeRpm(600); @@ -445,7 +444,7 @@ public class CommonFunctionalTest extends RusefiTestBase { ecu.changeRpm(2400); ecu.changeRpm(2000); chart = nextChart(); - EcuTestHelper.assertEquals("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP)); + EcuTestHelper.assertSomewhatClose("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP)); //assertEquals(1, SensorCentral.getInstance().getValue(Sensor.)); assertWaveNotNull(msg + " fuel SD #1", chart, EngineChart.INJECTOR_1); diff --git a/java_console/autotest/src/com/rusefi/f4discovery/PwmHardwareTest.java b/java_console/autotest/src/com/rusefi/f4discovery/PwmHardwareTest.java index 5b62ec0e88..aac3c5f908 100644 --- a/java_console/autotest/src/com/rusefi/f4discovery/PwmHardwareTest.java +++ b/java_console/autotest/src/com/rusefi/f4discovery/PwmHardwareTest.java @@ -14,6 +14,7 @@ import static com.rusefi.IoUtil.getDisableCommand; import static com.rusefi.IoUtil.getEnableCommand; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; import static com.rusefi.config.generated.Fields.*; +import static org.junit.Assert.assertEquals; /** * This test relies on jumpers connecting physical pins on Discovery: @@ -50,7 +51,7 @@ public class PwmHardwareTest extends RusefiTestBase { int totalTriggerErrorsNow = (int) SensorCentral.getInstance().getValueSource(Sensor.totalTriggerErrorCounter).getValue(); log.info("totalTriggerErrorsNow " + totalTriggerErrorsNow); - EcuTestHelper.assertTotallyEquals("totalTriggerErrorCounter", triggerErrors, totalTriggerErrorsNow); + assertEquals("totalTriggerErrorCounter", triggerErrors, totalTriggerErrorsNow); } @Test @@ -84,6 +85,6 @@ public class PwmHardwareTest extends RusefiTestBase { sleep(2 * Timeouts.SECOND); /* +-1% is still acceptable */ - EcuTestHelper.assertEquals("Idle PWM freq", FREQUENCY, SensorCentral.getInstance().getValue(Sensor.debugIntField1), 0.01); + EcuTestHelper.assertSomewhatClose("Idle PWM freq", FREQUENCY, SensorCentral.getInstance().getValue(Sensor.debugIntField1), 0.01); } } \ No newline at end of file diff --git a/java_console/autotest/src/com/rusefi/f4discovery/VssHardwareLoopTest.java b/java_console/autotest/src/com/rusefi/f4discovery/VssHardwareLoopTest.java index 37514d5325..514c657d1c 100644 --- a/java_console/autotest/src/com/rusefi/f4discovery/VssHardwareLoopTest.java +++ b/java_console/autotest/src/com/rusefi/f4discovery/VssHardwareLoopTest.java @@ -34,14 +34,14 @@ public class VssHardwareLoopTest extends RusefiTestBase { // moving second trigger to another pin ecu.sendCommand(CMD_TRIGGER_PIN + " 1 PA8"); - EcuTestHelper.assertEquals("VSS no input", 0, SensorCentral.getInstance().getValue(Sensor.VSS)); + EcuTestHelper.assertSomewhatClose("VSS no input", 0, SensorCentral.getInstance().getValue(Sensor.VSS)); // attaching VSS to trigger simulator since there is a jumper on test discovery ecu.sendCommand("set " + CMD_VSS_PIN + " pa5"); sleep(2 * Timeouts.SECOND); - EcuTestHelper.assertEquals("VSS with input", 3, SensorCentral.getInstance().getValue(Sensor.VSS)); + EcuTestHelper.assertSomewhatClose("VSS with input", 3, SensorCentral.getInstance().getValue(Sensor.VSS)); // not related to VSS test, just need to validate this somewhere, so this random test is as good as any if (ControllerConnectorState.firmwareVersion == null) diff --git a/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java b/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java index 2c3041afec..2daf8aa8da 100644 --- a/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java +++ b/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java @@ -62,24 +62,18 @@ public class EcuTestHelper { return linkManager; } - public static void assertEquals(double expected, double actual) { - EcuTestHelper.assertEquals("", expected, actual); + public static void assertSomewhatClose(double expected, double actual) { + EcuTestHelper.assertSomewhatClose("", expected, actual); } - public static void assertTotallyEquals(String msg, int expected, int actual) { - if (expected != actual) - throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); + public static void assertSomewhatClose(String msg, double expected, double actual) { + EcuTestHelper.assertSomewhatClose(msg, expected, actual, EngineReport.RATIO); } /** - * WARNING this is a LOOSE equals - * @see #assertTotallyEquals + * todo: it's time to leverage junit a bit more properly */ - public static void assertEquals(String msg, double expected, double actual) { - EcuTestHelper.assertEquals(msg, expected, actual, EngineReport.RATIO); - } - - public static void assertEquals(String msg, double expected, double actual, double ratio) { + public static void assertSomewhatClose(String msg, double expected, double actual, double ratio) { if (!isCloseEnough(expected, actual, ratio)) throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); }