only: reducing junit4

This commit is contained in:
rusefillc 2024-02-14 10:49:24 -05:00
parent 845327dd3c
commit 749d553410
4 changed files with 118 additions and 118 deletions

View File

@ -6,10 +6,11 @@ import com.rusefi.tools.tune.TuneCanTool;
import com.rusefi.tools.tune.TuneTools;
import com.rusefi.tune.xml.Msq;
import com.rusefi.tune.xml.Page;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
public class LoadOlderTuneTest {
@Test
@ -28,118 +29,118 @@ public class LoadOlderTuneTest {
StringBuilder sb = TuneCanTool.getTunePatch(lessOldDefaultTune, customOldTune, ini, TuneReadWriteTest.TUNE_NAME, new StringBuilder());
assertEquals(" // default \"Single Coil\"\n" +
" engineConfiguration->ignitionMode = IM_ONE_COIL;\n" +
" // default 4.0\n" +
" engineConfiguration->cylindersCount = 4;\n" +
" // default \"60/2\"\n" +
" engineConfiguration->trigger.type = TT_ONE_PLUS_ONE;\n" +
" // default 1000.0\n" +
" engineConfiguration->tps1SecondaryMin = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->tps1SecondaryMax = 1000;\n" +
" // default 1000.0\n" +
" engineConfiguration->tps2SecondaryMin = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->tps2SecondaryMax = 1000;\n" +
" // default 5.0\n" +
" engineConfiguration->throttlePedalSecondaryUpVoltage = 0;\n" +
" // default 65.0\n" +
" engineConfiguration->mc33_hvolt = 0;\n" +
" // default 13000.0\n" +
" engineConfiguration->mc33_i_boost = 0;\n" +
" // default 9400.0\n" +
" engineConfiguration->mc33_i_peak = 0;\n" +
" // default 3700.0\n" +
" engineConfiguration->mc33_i_hold = 0;\n" +
" // default 400.0\n" +
" engineConfiguration->mc33_t_max_boost = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->mc33_t_peak_off = 0;\n" +
" // default 700.0\n" +
" engineConfiguration->mc33_t_peak_tot = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->mc33_t_bypass = 0;\n" +
" // default 60.0\n" +
" engineConfiguration->mc33_t_hold_off = 0;\n" +
" // default 10000.0\n" +
" engineConfiguration->mc33_t_hold_tot = 0;\n" +
" // default \"PULLUP\"\n" +
" engineConfiguration->clutchDownPinMode = 1;\n" +
" // default \"PULLUP\"\n" +
" engineConfiguration->clutchUpPinMode = 1;\n" +
" // default 410.0\n" +
" engineConfiguration->mapErrorDetectionTooHigh = 250;\n" +
" // default 3.0\n" +
" engineConfiguration->idleStepperReactionTime = 10;\n" +
" // default 200.0\n" +
" engineConfiguration->idleStepperTotalSteps = 150;\n" +
" // default \"true\"\n" +
" engineConfiguration->stepperForceParkingEveryRestart = false;\n" +
" // default -20.0\n" +
" engineConfiguration->idleRpmPid.minValue = 0;\n" +
" // default 20.0\n" +
" engineConfiguration->idleRpmPid.maxValue = 99;\n" +
" // default -20.0\n" +
" engineConfiguration->idlerpmpid_iTermMin = -200;\n" +
" // default 20.0\n" +
" engineConfiguration->idlerpmpid_iTermMax = 200;\n" +
" // default 0.0\n" +
" engineConfiguration->idleRpmPid.periodMs = 10;\n" +
" // default 300.0\n" +
" engineConfiguration->idlePidRpmUpperLimit = 0;\n" +
" // default 5.0\n" +
" engineConfiguration->idlePidDeactivationTpsThreshold = 2;\n" +
" // default 0.10000000149011612\n" +
" engineConfiguration->idleTimingPid.pFactor = 0;\n" +
" // default -10.0\n" +
" engineConfiguration->idleTimingPid.minValue = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->idleTimingPid.maxValue = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->warningPeriod = 10;\n" +
" // default \"false\"\n" +
" engineConfiguration->isHip9011Enabled = true;\n" +
" // default 0.0\n" +
" engineConfiguration->hip9011PrescalerAndSDO = 6;\n" +
" // default 20.0\n" +
" engineConfiguration->knockDetectionWindowStart = 35;\n" +
" // default 60.0\n" +
" engineConfiguration->knockDetectionWindowEnd = 135;\n" +
" // default \"false\"\n" +
" engineConfiguration->is_enabled_spi_3 = true;\n" +
" // default 33.0\n" +
" engineConfiguration->auxPid[0].offset = 0;\n" +
" // default 2.0\n" +
" engineConfiguration->auxPid[0].pFactor = 0;\n" +
" // default 0.004999999888241291\n" +
" engineConfiguration->auxPid[0].iFactor = 0;\n" +
" // default 5.333333492279053\n" +
" engineConfiguration->vbattDividerCoeff = 8.6;\n" +
" // default 0.0\n" +
" engineConfiguration->alternatorControl.minValue = 10;\n" +
" // default \"DEFAULT\"\n" +
" engineConfiguration->startStopButtonMode = 0;\n" +
" // default 3.0\n" +
" engineConfiguration->startCrankingDuration = 7;\n" +
" // default \"Duty cycle\"\n" +
" engineConfiguration->tachPulseDurationAsDutyCycle = false;\n" +
" // defa", sb.substring(0, 3500));
" engineConfiguration->ignitionMode = IM_ONE_COIL;\n" +
" // default 4.0\n" +
" engineConfiguration->cylindersCount = 4;\n" +
" // default \"60/2\"\n" +
" engineConfiguration->trigger.type = TT_ONE_PLUS_ONE;\n" +
" // default 1000.0\n" +
" engineConfiguration->tps1SecondaryMin = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->tps1SecondaryMax = 1000;\n" +
" // default 1000.0\n" +
" engineConfiguration->tps2SecondaryMin = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->tps2SecondaryMax = 1000;\n" +
" // default 5.0\n" +
" engineConfiguration->throttlePedalSecondaryUpVoltage = 0;\n" +
" // default 65.0\n" +
" engineConfiguration->mc33_hvolt = 0;\n" +
" // default 13000.0\n" +
" engineConfiguration->mc33_i_boost = 0;\n" +
" // default 9400.0\n" +
" engineConfiguration->mc33_i_peak = 0;\n" +
" // default 3700.0\n" +
" engineConfiguration->mc33_i_hold = 0;\n" +
" // default 400.0\n" +
" engineConfiguration->mc33_t_max_boost = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->mc33_t_peak_off = 0;\n" +
" // default 700.0\n" +
" engineConfiguration->mc33_t_peak_tot = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->mc33_t_bypass = 0;\n" +
" // default 60.0\n" +
" engineConfiguration->mc33_t_hold_off = 0;\n" +
" // default 10000.0\n" +
" engineConfiguration->mc33_t_hold_tot = 0;\n" +
" // default \"PULLUP\"\n" +
" engineConfiguration->clutchDownPinMode = 1;\n" +
" // default \"PULLUP\"\n" +
" engineConfiguration->clutchUpPinMode = 1;\n" +
" // default 410.0\n" +
" engineConfiguration->mapErrorDetectionTooHigh = 250;\n" +
" // default 3.0\n" +
" engineConfiguration->idleStepperReactionTime = 10;\n" +
" // default 200.0\n" +
" engineConfiguration->idleStepperTotalSteps = 150;\n" +
" // default \"true\"\n" +
" engineConfiguration->stepperForceParkingEveryRestart = false;\n" +
" // default -20.0\n" +
" engineConfiguration->idleRpmPid.minValue = 0;\n" +
" // default 20.0\n" +
" engineConfiguration->idleRpmPid.maxValue = 99;\n" +
" // default -20.0\n" +
" engineConfiguration->idlerpmpid_iTermMin = -200;\n" +
" // default 20.0\n" +
" engineConfiguration->idlerpmpid_iTermMax = 200;\n" +
" // default 0.0\n" +
" engineConfiguration->idleRpmPid.periodMs = 10;\n" +
" // default 300.0\n" +
" engineConfiguration->idlePidRpmUpperLimit = 0;\n" +
" // default 5.0\n" +
" engineConfiguration->idlePidDeactivationTpsThreshold = 2;\n" +
" // default 0.10000000149011612\n" +
" engineConfiguration->idleTimingPid.pFactor = 0;\n" +
" // default -10.0\n" +
" engineConfiguration->idleTimingPid.minValue = 0;\n" +
" // default 10.0\n" +
" engineConfiguration->idleTimingPid.maxValue = 0;\n" +
" // default 0.0\n" +
" engineConfiguration->warningPeriod = 10;\n" +
" // default \"false\"\n" +
" engineConfiguration->isHip9011Enabled = true;\n" +
" // default 0.0\n" +
" engineConfiguration->hip9011PrescalerAndSDO = 6;\n" +
" // default 20.0\n" +
" engineConfiguration->knockDetectionWindowStart = 35;\n" +
" // default 60.0\n" +
" engineConfiguration->knockDetectionWindowEnd = 135;\n" +
" // default \"false\"\n" +
" engineConfiguration->is_enabled_spi_3 = true;\n" +
" // default 33.0\n" +
" engineConfiguration->auxPid[0].offset = 0;\n" +
" // default 2.0\n" +
" engineConfiguration->auxPid[0].pFactor = 0;\n" +
" // default 0.004999999888241291\n" +
" engineConfiguration->auxPid[0].iFactor = 0;\n" +
" // default 5.333333492279053\n" +
" engineConfiguration->vbattDividerCoeff = 8.6;\n" +
" // default 0.0\n" +
" engineConfiguration->alternatorControl.minValue = 10;\n" +
" // default \"DEFAULT\"\n" +
" engineConfiguration->startStopButtonMode = 0;\n" +
" // default 3.0\n" +
" engineConfiguration->startCrankingDuration = 7;\n" +
" // default \"Duty cycle\"\n" +
" engineConfiguration->tachPulseDurationAsDutyCycle = false;\n" +
" // defa", sb.substring(0, 3500));
}
@Test
public void testLegacyCustomEnumOrdinal() {
assertThrows(IllegalStateException.class, () -> {
String tsCustomLine = "bits, U08, @OFFSET@, [0:1], \"Single Coil\", \"Individual Coils\", \"Wasted Spark\", \"Two Distributors\"";
Assertions.assertThrows(IllegalStateException.class, () -> {
String tsCustomLine = "bits, U08, @OFFSET@, [0:1], \"Single Coil\", \"Individual Coils\", \"Wasted Spark\", \"Two Distributors\"";
Assert.assertEquals(0, TuneTools.resolveEnumByName(tsCustomLine, "One coil"));
});
assertEquals(0, TuneTools.resolveEnumByName(tsCustomLine, "One coil"));
});
}
@Test
public void testCustomEnumOrdinal() {
String tsCustomLine = "bits, U08, @OFFSET@, [0:1], \"Single Coil\", \"Individual Coils\", \"Wasted Spark\", \"Two Distributors\"";
Assert.assertEquals(0, TuneTools.resolveEnumByName(tsCustomLine, "Single coil"));
Assert.assertEquals(3, TuneTools.resolveEnumByName(tsCustomLine, "Two Distributors"));
assertEquals(0, TuneTools.resolveEnumByName(tsCustomLine, "Single coil"));
assertEquals(3, TuneTools.resolveEnumByName(tsCustomLine, "Two Distributors"));
}
}

View File

@ -2,14 +2,13 @@ package com.rusefi.tune;
import com.opensr5.ini.IniFileModel;
import com.rusefi.tools.tune.WriteSimulatorConfiguration;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull;
public class ReadCurrentIniTest {
@Test
public void test() {
IniFileModel ini = new IniFileModel().readIniFile("../" + WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR);
assertNotNull(ini);
Assertions.assertNotNull(ini);
}
}

View File

@ -2,13 +2,14 @@ package com.rusefi.tune;
import com.rusefi.tools.tune.TS2C;
import com.rusefi.tools.tune.TableData;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TableDataTest {
@Test

View File

@ -11,7 +11,6 @@ import com.rusefi.tools.tune.TS2C;
import com.rusefi.tools.tune.TuneCanTool;
import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -32,9 +31,9 @@ public class TuneReadWriteTest {
@Test
public void testIniReader() throws IOException {
assertTrue(model.getTables().contains("fueltable"));
Assert.assertEquals(21, model.getTables().size());
Assert.assertEquals("fuelRpmBins", model.getXBin("FUELTable"));
Assert.assertEquals("fuelLoadBins", model.getYBin("fuelTable"));
assertEquals(21, model.getTables().size());
assertEquals("fuelRpmBins", model.getXBin("FUELTable"));
assertEquals("fuelLoadBins", model.getYBin("fuelTable"));
String tableName = "ignitionIatCorrTable";
String xRpmBinsName = model.getXBin(tableName);
@ -44,10 +43,10 @@ public class TuneReadWriteTest {
CurveData xRpmCurve = CurveData.valueOf(TUNE_NAME, xRpmBinsName, model);
Assert.assertEquals("static const float hardCodedignitionIatCorrRpmBins[16] = " +
assertEquals("static const float hardCodedignitionIatCorrRpmBins[16] = " +
"{880.0, 1260.0, 1640.0, 2020.0, 2400.0, 2780.0, 3000.0, 3380.0, 3760.0, 4140.0, 4520.0, 5000.0, 5700.0, 6500.0, 7200.0, 8000.0};\n", xRpmCurve.getCsourceCode());
Assert.assertEquals("static void cannedignitionIatCorrRpmBins() {\n" +
assertEquals("static void cannedignitionIatCorrRpmBins() {\n" +
"\tstatic const float hardCodedignitionIatCorrRpmBins[16] = {880.0, 1260.0, 1640.0, 2020.0, 2400.0, 2780.0, 3000.0, 3380.0, 3760.0, 4140.0, 4520.0, 5000.0, 5700.0, 6500.0, 7200.0, 8000.0};\n" +
"\tcopyArray(config->ignitionIatCorrRpmBins, hardCodedignitionIatCorrRpmBins);\n" +
"}\n" +
@ -147,7 +146,7 @@ public class TuneReadWriteTest {
Constant flow = tsTune.findPage().findParameter("injector_flow");
assertNotNull(flow);
Assert.assertEquals("2", flow.getDigits());
assertEquals("2", flow.getDigits());
ConfigurationImage tsBinaryData = tsTune.asImage(model, LEGACY_TOTAL_CONFIG_SIZE);
@ -171,11 +170,11 @@ public class TuneReadWriteTest {
Constant batteryCorrection = tuneFromBinary.findPage().findParameter("injector_battLagCorrBins");
assertNotNull(batteryCorrection);
Assert.assertEquals("2", batteryCorrection.getDigits());
assertEquals("2", batteryCorrection.getDigits());
Constant flow = tuneFromBinary.findPage().findParameter("injector_flow");
assertNotNull(flow);
Assert.assertEquals("2", flow.getDigits());
assertEquals("2", flow.getDigits());
Constant nonEmptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas1");
assertNotNull(nonEmptyFormula);
@ -188,7 +187,7 @@ public class TuneReadWriteTest {
Constant enumField = tuneFromBinary.findPage().findParameter("acRelayPin");
// quotes are expected
Assert.assertEquals("\"NONE\"", enumField.getValue());
assertEquals("\"NONE\"", enumField.getValue());
// and now reading that XML back
Msq tuneFromFile = Msq.readTune(fileName);