only:junit5

This commit is contained in:
rusefillc 2023-12-15 11:29:56 -05:00
parent 9644a01d10
commit c2b1ba7e01
23 changed files with 335 additions and 319 deletions

View File

@ -2,8 +2,8 @@ package com.rusefi.pinout;
import com.rusefi.ReaderStateImpl;
import com.rusefi.newparse.DefinitionsState;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.*;
@ -13,7 +13,7 @@ import static junit.framework.TestCase.assertFalse;
public class PinoutLogicHellen112_17_Test {
@Test
@Ignore // this was only useful while figuring out the problem
@Disabled // this was only useful while figuring out the problem
public void testRealFiled() throws IOException {
// a bit nasty, do we have similar anywhere else already?
FileSystemBoardInputsReaderImpl.PREFIX = FIRMWARE + File.separator;

View File

@ -3,7 +3,7 @@ package com.rusefi.pinout;
import com.rusefi.ReaderStateImpl;
import com.rusefi.enum_reader.Value;
import com.rusefi.newparse.DefinitionsState;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.util.Arrays;

View File

@ -2,7 +2,7 @@ package com.rusefi.pinout;
import com.rusefi.EnumsReader;
import com.rusefi.enum_reader.Value;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;

View File

@ -4,7 +4,7 @@ import com.rusefi.ReaderStateImpl;
import com.rusefi.TsFileContent;
import com.rusefi.output.TSProjectConsumer;
import com.rusefi.util.Output;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.*;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.output.BaseCHeaderConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,7 +3,7 @@ package com.rusefi.test;
import com.rusefi.EnumsReader;
import com.rusefi.VariableRegistry;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileReader;

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.JavaFieldsConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,9 +3,9 @@ package com.rusefi.test;
import com.rusefi.*;
import com.rusefi.output.*;
import com.rusefi.parse.TypesHelper;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Andrey Belomutskiy, (c) 2013-2020
@ -22,7 +22,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getArraySizes().length, 1);
assertEquals(cf.getArraySizes()[0], 8);
assertEquals(cf.getSize(null), 8);
assertFalse("isIterate", cf.isIterate());
assertFalse(cf.isIterate(), "isIterate");
}
}
@ -36,7 +36,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getArraySizes()[0], 8);
assertEquals(cf.getArraySizes()[1], 16);
assertEquals(cf.getSize(null), 128);
assertFalse("isIterate", cf.isIterate());
assertFalse(cf.isIterate(), "isIterate");
}
}
@ -68,17 +68,19 @@ public class ConfigFieldParserTest {
"; total TS size = 12\n", tsProjectConsumer.getContent());
}
@Test(expected = IllegalStateException.class)
@Test
public void testSameFieldTwice() {
assertThrows(IllegalStateException.class, () -> {
String test = "struct pid_s\n" +
"int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"int afr_type2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"end_struct\n";
"int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"int afr_type2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"end_struct\n";
ReaderStateImpl state = new ReaderStateImpl();
BaseCHeaderConsumer consumer = new BaseCHeaderConsumer();
state.readBufferedReader(test, consumer);
});
}
@Test
@ -205,13 +207,15 @@ public class ConfigFieldParserTest {
new ReaderStateImpl().readBufferedReader(test);
}
@Test(expected = IllegalStateException.class)
@Test
public void invalidDefine() {
assertThrows(IllegalStateException.class, () -> {
String test = "struct pid_s\n" +
VariableRegistry.DEFINE + " show show_Hellen121vag_presets true\n" +
"end_struct\n" +
"";
VariableRegistry.DEFINE + " show show_Hellen121vag_presets true\n" +
"end_struct\n" +
"";
new ReaderStateImpl().readBufferedReader(test);
});
}
@Test
@ -364,7 +368,7 @@ public class ConfigFieldParserTest {
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int field");
assertEquals(cf.getType(), "int");
assertEquals("Name", cf.getName(), "field");
assertEquals(cf.getName(), "field", "Unexpected Field Name");
}
{
@ -671,7 +675,7 @@ public class ConfigFieldParserTest {
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int field");
assertEquals(cf.getType(), "int");
assertEquals("Name", cf.getName(), "field");
assertEquals(cf.getName(), "field", "Name");
}
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int_4 fie4_ld");
@ -682,7 +686,7 @@ public class ConfigFieldParserTest {
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int_8 fi_eld;comm_;ts,1,1");
assertEquals(cf.getType(), "int_8");
assertEquals(cf.getName(), "fi_eld");
assertEquals("Comment", cf.getComment(), "comm_");
assertEquals(cf.getComment(), "comm_", "Comment");
assertEquals(cf.getTsInfo(), "ts,1,1");
}
{
@ -690,7 +694,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getType(), "int");
assertEquals(cf.getArraySizes().length, 1);
assertEquals(cf.getArraySizes()[0], 3);
assertTrue("isIterate", cf.isIterate());
assertTrue(cf.isIterate(), "isIterate");
}
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int16_t crankingRpm;This,. value controls what RPM values we consider 'cranking' (any RPM below 'crankingRpm')\\nAnything above 'crankingRpm' would be 'running'");

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.EnumsReader;
import com.rusefi.ReaderStateImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.FiringOrderTSLogic;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class FiringOrderTSLogicTest {
@Test

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.FragmentDialogConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,272 +3,276 @@ package com.rusefi.test;
import com.rusefi.MaybeSemicolonWasMissedException;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.GetConfigValueConsumer;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class GetConfigValueConsumerTest {
@Test
public void testStructArrayAndCharArgument() {
ReaderStateImpl state = new ReaderStateImpl();
String test = "struct total\n" +
"custom lua_script_t 200 string, ASCII, @OFFSET@, 200\n" +
"lua_script_t luaScript;\n" +
"struct dc_io\n" +
"\tint disablePin;\n" +
"end_struct\n" +
"\tdc_io[2 iterate] etbIn\n" +
"end_struct\n";
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
@Test
public void testStructArrayAndCharArgument() {
ReaderStateImpl state = new ReaderStateImpl();
String test = "struct total\n" +
"custom lua_script_t 200 string, ASCII, @OFFSET@, 200\n" +
"lua_script_t luaScript;\n" +
"struct dc_io\n" +
"\tint disablePin;\n" +
"end_struct\n" +
"\tdc_io[2 iterate] etbIn\n" +
"end_struct\n";
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
assertEquals(
"float getConfigValueByName(const char *name) {\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getCompleteGetterBody());
}
assertEquals(
"float getConfigValueByName(const char *name) {\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getCompleteGetterBody());
}
@Test
public void generateEmbeddedStruct() {
ReaderStateImpl state = new ReaderStateImpl();
String test = "struct total\n" +
"struct_no_prefix thermistor_conf_s @brief Thermistor known values\n" +
"float tempC_1;these values are in Celcius;\"*C\", 1, 0, -40, 200, 1\n" +
"\n" +
"end_struct\n" +
"struct ThermistorConf @brief Thermistor curve parameters\n" +
"\tthermistor_conf_s config;\n" +
"\tint adcChannel;\n" +
"end_struct\n" +
"ThermistorConf iat;\n" +
"end_struct\n";
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
@Test
public void generateEmbeddedStruct() {
ReaderStateImpl state = new ReaderStateImpl();
String test = "struct total\n" +
"struct_no_prefix thermistor_conf_s @brief Thermistor known values\n" +
"float tempC_1;these values are in Celcius;\"*C\", 1, 0, -40, 200, 1\n" +
"\n" +
"end_struct\n" +
"struct ThermistorConf @brief Thermistor curve parameters\n" +
"\tthermistor_conf_s config;\n" +
"\tint adcChannel;\n" +
"end_struct\n" +
"ThermistorConf iat;\n" +
"end_struct\n";
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
assertEquals("\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"\t\tcase -672272162:\n" +
"\t{\n" +
"\t\tconfig->iat.config.tempC_1 = value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t\tcase -1237776078:\n" +
"\t{\n" +
"\t\tconfig->iat.adcChannel = (int)value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t}\n" +
"\treturn 0;\n",
getConfigValueConsumer.getSetterBody());
assertEquals("\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"\t\tcase -672272162:\n" +
"\t{\n" +
"\t\tconfig->iat.config.tempC_1 = value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t\tcase -1237776078:\n" +
"\t{\n" +
"\t\tconfig->iat.adcChannel = (int)value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t}\n" +
"\treturn 0;\n",
getConfigValueConsumer.getSetterBody());
assertEquals("// generated by GetConfigValueConsumer.java\n" +
"#include \"pch.h\"\n" +
"#include \"value_lookup.h\"\n" +
"float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// iat.config.tempC_1\n" +
"\t\tcase -672272162:\n" +
"\t\t\treturn config->iat.config.tempC_1;\n" +
"// iat.adcChannel\n" +
"\t\tcase -1237776078:\n" +
"\t\t\treturn config->iat.adcChannel;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n" +
"bool setConfigValueByName(const char *name, float value) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"\t\tcase -672272162:\n" +
"\t{\n" +
"\t\tconfig->iat.config.tempC_1 = value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t\tcase -1237776078:\n" +
"\t{\n" +
"\t\tconfig->iat.adcChannel = (int)value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t}\n" +
"\treturn 0;\n" +
"}\n", getConfigValueConsumer.getContent());
assertEquals("// generated by GetConfigValueConsumer.java\n" +
"#include \"pch.h\"\n" +
"#include \"value_lookup.h\"\n" +
"float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// iat.config.tempC_1\n" +
"\t\tcase -672272162:\n" +
"\t\t\treturn config->iat.config.tempC_1;\n" +
"// iat.adcChannel\n" +
"\t\tcase -1237776078:\n" +
"\t\t\treturn config->iat.adcChannel;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n" +
"bool setConfigValueByName(const char *name, float value) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"\t\tcase -672272162:\n" +
"\t{\n" +
"\t\tconfig->iat.config.tempC_1 = value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t\tcase -1237776078:\n" +
"\t{\n" +
"\t\tconfig->iat.adcChannel = (int)value;\n" +
"\t\treturn 1;\n" +
"\t}\n" +
"\t}\n" +
"\treturn 0;\n" +
"}\n", getConfigValueConsumer.getContent());
assertEquals("float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// iat.config.tempC_1\n" +
"\t\tcase -672272162:\n" +
"\t\t\treturn config->iat.config.tempC_1;\n" +
"// iat.adcChannel\n" +
"\t\tcase -1237776078:\n" +
"\t\t\treturn config->iat.adcChannel;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getCompleteGetterBody());
}
assertEquals("float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// iat.config.tempC_1\n" +
"\t\tcase -672272162:\n" +
"\t\t\treturn config->iat.config.tempC_1;\n" +
"// iat.adcChannel\n" +
"\t\tcase -1237776078:\n" +
"\t\t\treturn config->iat.adcChannel;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getCompleteGetterBody());
}
@Test
public void generateGetConfig() {
String test = "struct total\n" +
"struct_no_prefix thermistor_conf_s @brief Thermistor known values\n" +
"float tempC_1;these values are in Celcius;\"*C\", 1, 0, -40, 200, 1\n" +
"\n" +
"custom air_pressure_sensor_type_e 4 bits, U32, @OFFSET@, [0:4], \"Custom\", \"DENSO183\", \"MPX4250\", \"HONDA3BAR\", \"NEON_2003\", \"22012AA090\", \"3 Bar\", \"MPX4100\", \"Toyota 89420-02010\", \"MPX4250A\", \"Bosch 2.5\", \"Mazda1Bar\", \"GM 2 Bar\", \"GM 1 Bar\", \"MPXH6400\"\n" +
"struct air_pressure_sensor_config_s\n" +
"float highValue;kPa value at high volts;\"kpa\", 1, 0, -400, 800, 2\n" +
"air_pressure_sensor_type_e type;\n" +
"int hwChannel;\n" +
"uint8_t[3] alignmentFill;;\"unit\", 1, 0, 0, 100, 0\n" +
"\n" +
"end_struct\n" +
"\n" +
"struct MAP_sensor_config_s @brief MAP averaging configuration\n" +
"float[6] samplingAngleBins;;\"\", 1, 0, 0, 18000, 2\n" +
"air_pressure_sensor_config_s sensor\n" +
"end_struct\n" +
"MAP_sensor_config_s map;@see isMapAveragingEnabled\n" +
"struct injector_s\n" +
"\tfloat flow;This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min;\"cm3/min\", 1, 0, 0, 99999, 2\n" +
"\n" +
"float[8] battLagCorr;ms delay between injector open and close dead times;\"ms\", 1, 0, 0, 50, 2\n" +
"\n" +
"end_struct\n" +
"\n" +
"injector_s injector\n" +
"\tint[12 iterate] ignitionPins;\n" +
"\tfloat bias_resistor;Pull-up resistor value on your board;\"Ohm\", 1, 0, 0, 200000, 1\n" +
"end_struct\n" +
"struct ThermistorConf @brief Thermistor curve parameters\n" +
"\tthermistor_conf_s config;\n" +
"\tint adcChannel;\n" +
"end_struct\n" +
"ThermistorConf clt;todo: merge with channel settings, use full-scale Thermistor here!\n" +
"bit issue_294_31,\"si_example\",\"nada_example\"\n" +
"uint8_t[2 iterate] autoscale knock;;\"\",1, 0, 0, 0, 0\n" +
"\tuint16_t autoscale baseFuel;@@GAUGE_NAME_FUEL_BASE@@\\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections;\"mg\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"float afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint16_t autoscale speedToRpmRatio;s2rpm;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"uint8_t afr_typet;;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint8_t autoscale vehicleSpeedKph;;\"kph\",1, 0, 0, 0, 0\n" +
"bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" +
"\tuint8_t unused37;;\"\",1, 0, 0, 0, 0\n" +
"bit enableFan1WithAc;Turn on this fan when AC is on.\n" +
"end_struct\n";
ReaderStateImpl state = new ReaderStateImpl();
state.getVariableRegistry().register("PACK_MULT_PERCENT", 100);
state.getVariableRegistry().register("GAUGE_NAME_FUEL_BASE", "hello");
@Test
public void generateGetConfig() {
String test = "struct total\n" +
"struct_no_prefix thermistor_conf_s @brief Thermistor known values\n" +
"float tempC_1;these values are in Celcius;\"*C\", 1, 0, -40, 200, 1\n" +
"\n" +
"custom air_pressure_sensor_type_e 4 bits, U32, @OFFSET@, [0:4], \"Custom\", \"DENSO183\", \"MPX4250\", \"HONDA3BAR\", \"NEON_2003\", \"22012AA090\", \"3 Bar\", \"MPX4100\", \"Toyota 89420-02010\", \"MPX4250A\", \"Bosch 2.5\", \"Mazda1Bar\", \"GM 2 Bar\", \"GM 1 Bar\", \"MPXH6400\"\n" +
"struct air_pressure_sensor_config_s\n" +
"float highValue;kPa value at high volts;\"kpa\", 1, 0, -400, 800, 2\n" +
"air_pressure_sensor_type_e type;\n" +
"int hwChannel;\n" +
"uint8_t[3] alignmentFill;;\"unit\", 1, 0, 0, 100, 0\n" +
"\n" +
"end_struct\n" +
"\n" +
"struct MAP_sensor_config_s @brief MAP averaging configuration\n" +
"float[6] samplingAngleBins;;\"\", 1, 0, 0, 18000, 2\n" +
"air_pressure_sensor_config_s sensor\n" +
"end_struct\n" +
"MAP_sensor_config_s map;@see isMapAveragingEnabled\n" +
"struct injector_s\n" +
"\tfloat flow;This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min;\"cm3/min\", 1, 0, 0, 99999, 2\n" +
"\n" +
"float[8] battLagCorr;ms delay between injector open and close dead times;\"ms\", 1, 0, 0, 50, 2\n" +
"\n" +
"end_struct\n" +
"\n" +
"injector_s injector\n" +
"\tint[12 iterate] ignitionPins;\n" +
"\tfloat bias_resistor;Pull-up resistor value on your board;\"Ohm\", 1, 0, 0, 200000, 1\n" +
"end_struct\n" +
"struct ThermistorConf @brief Thermistor curve parameters\n" +
"\tthermistor_conf_s config;\n" +
"\tint adcChannel;\n" +
"end_struct\n" +
"ThermistorConf clt;todo: merge with channel settings, use full-scale Thermistor here!\n" +
"bit issue_294_31,\"si_example\",\"nada_example\"\n" +
"uint8_t[2 iterate] autoscale knock;;\"\",1, 0, 0, 0, 0\n" +
"\tuint16_t autoscale baseFuel;@@GAUGE_NAME_FUEL_BASE@@\\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections;\"mg\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"float afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint16_t autoscale speedToRpmRatio;s2rpm;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"uint8_t afr_typet;;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint8_t autoscale vehicleSpeedKph;;\"kph\",1, 0, 0, 0, 0\n" +
"bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" +
"\tuint8_t unused37;;\"\",1, 0, 0, 0, 0\n" +
"bit enableFan1WithAc;Turn on this fan when AC is on.\n" +
"end_struct\n";
ReaderStateImpl state = new ReaderStateImpl();
state.getVariableRegistry().register("PACK_MULT_PERCENT", 100);
state.getVariableRegistry().register("GAUGE_NAME_FUEL_BASE", "hello");
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
assertEquals("// generated by GetConfigValueConsumer.java\n" +
"#include \"pch.h\"\n" +
"#include \"value_lookup.h\"\n" +
"float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// clt.config.tempC_1\n" +
"\t\tcase -1832527325:\n" +
"\t\t\treturn config->clt.config.tempC_1;\n" +
"// clt.config.map.sensor.highValue\n" +
"\t\tcase 1819278123:\n" +
"\t\t\treturn config->clt.config.map.sensor.highValue;\n" +
"// clt.config.map.sensor.hwChannel\n" +
"\t\tcase 581685574:\n" +
"\t\t\treturn config->clt.config.map.sensor.hwChannel;\n" +
"// clt.config.injector.flow\n" +
"\t\tcase 382574846:\n" +
"\t\t\treturn config->clt.config.injector.flow;\n" +
"// clt.config.bias_resistor\n" +
"\t\tcase -653172717:\n" +
"\t\t\treturn config->clt.config.bias_resistor;\n" +
"// clt.adcChannel\n" +
"\t\tcase -1144186889:\n" +
"\t\t\treturn config->clt.adcChannel;\n" +
"// issue_294_31\n" +
"\t\tcase -1571463185:\n" +
"\t\t\treturn config->issue_294_31;\n" +
"// baseFuel\n" +
"\t\tcase 727098956:\n" +
"\t\t\treturn config->baseFuel;\n" +
"// afr_type\n" +
"\t\tcase -1120008897:\n" +
"\t\t\treturn config->afr_type;\n" +
"// speedToRpmRatio\n" +
"\t\tcase -685727673:\n" +
"\t\t\treturn config->speedToRpmRatio;\n" +
"// afr_typet\n" +
"\t\tcase 1694412179:\n" +
"\t\t\treturn config->afr_typet;\n" +
"// vehicleSpeedKph\n" +
"\t\tcase -1925174695:\n" +
"\t\t\treturn config->vehicleSpeedKph;\n" +
"// isForcedInduction\n" +
"\t\tcase -617915487:\n" +
"\t\t\treturn config->isForcedInduction;\n" +
"// enableFan1WithAc\n" +
"\t\tcase -298185774:\n" +
"\t\t\treturn config->enableFan1WithAc;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getHeaderAndGetter());
assertEquals("// generated by GetConfigValueConsumer.java\n" +
"#include \"pch.h\"\n" +
"#include \"value_lookup.h\"\n" +
"float getConfigValueByName(const char *name) {\n" +
"\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" +
"// clt.config.tempC_1\n" +
"\t\tcase -1832527325:\n" +
"\t\t\treturn config->clt.config.tempC_1;\n" +
"// clt.config.map.sensor.highValue\n" +
"\t\tcase 1819278123:\n" +
"\t\t\treturn config->clt.config.map.sensor.highValue;\n" +
"// clt.config.map.sensor.hwChannel\n" +
"\t\tcase 581685574:\n" +
"\t\t\treturn config->clt.config.map.sensor.hwChannel;\n" +
"// clt.config.injector.flow\n" +
"\t\tcase 382574846:\n" +
"\t\t\treturn config->clt.config.injector.flow;\n" +
"// clt.config.bias_resistor\n" +
"\t\tcase -653172717:\n" +
"\t\t\treturn config->clt.config.bias_resistor;\n" +
"// clt.adcChannel\n" +
"\t\tcase -1144186889:\n" +
"\t\t\treturn config->clt.adcChannel;\n" +
"// issue_294_31\n" +
"\t\tcase -1571463185:\n" +
"\t\t\treturn config->issue_294_31;\n" +
"// baseFuel\n" +
"\t\tcase 727098956:\n" +
"\t\t\treturn config->baseFuel;\n" +
"// afr_type\n" +
"\t\tcase -1120008897:\n" +
"\t\t\treturn config->afr_type;\n" +
"// speedToRpmRatio\n" +
"\t\tcase -685727673:\n" +
"\t\t\treturn config->speedToRpmRatio;\n" +
"// afr_typet\n" +
"\t\tcase 1694412179:\n" +
"\t\t\treturn config->afr_typet;\n" +
"// vehicleSpeedKph\n" +
"\t\tcase -1925174695:\n" +
"\t\t\treturn config->vehicleSpeedKph;\n" +
"// isForcedInduction\n" +
"\t\tcase -617915487:\n" +
"\t\t\treturn config->isForcedInduction;\n" +
"// enableFan1WithAc\n" +
"\t\tcase -298185774:\n" +
"\t\t\treturn config->enableFan1WithAc;\n" +
"\t}\n" +
"\treturn EFI_ERROR_CODE;\n" +
"}\n", getConfigValueConsumer.getHeaderAndGetter());
assertEquals("### clt.config.tempC_1\n" +
"these values are in Celcius\n" +
"\n" +
"### clt.config.map.sensor.highValue\n" +
"kPa value at high volts\n" +
"\n" +
"### clt.config.map.sensor.hwChannel\n" +
"\n" +
"\n" +
"### clt.config.injector.flow\n" +
"This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min\n" +
"\n" +
"### clt.config.bias_resistor\n" +
"Pull-up resistor value on your board\n" +
"\n" +
"### clt.adcChannel\n" +
"\n" +
"\n" +
"### issue_294_31\n" +
"\n" +
"\n" +
"### baseFuel\n" +
"@@GAUGE_NAME_FUEL_BASE@@\\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections\n" +
"\n" +
"### afr_type\n" +
"PID dTime\n" +
"\n" +
"### speedToRpmRatio\n" +
"s2rpm\n" +
"\n" +
"### afr_typet\n" +
"\n" +
"\n" +
"### vehicleSpeedKph\n" +
"\n" +
"\n" +
"### isForcedInduction\n" +
"Does the vehicle have a turbo or supercharger?\n" +
"\n" +
"### enableFan1WithAc\n" +
"Turn on this fan when AC is on.\n" +
"\n", getConfigValueConsumer.getMdContent());
}
assertEquals("### clt.config.tempC_1\n" +
"these values are in Celcius\n" +
"\n" +
"### clt.config.map.sensor.highValue\n" +
"kPa value at high volts\n" +
"\n" +
"### clt.config.map.sensor.hwChannel\n" +
"\n" +
"\n" +
"### clt.config.injector.flow\n" +
"This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min\n" +
"\n" +
"### clt.config.bias_resistor\n" +
"Pull-up resistor value on your board\n" +
"\n" +
"### clt.adcChannel\n" +
"\n" +
"\n" +
"### issue_294_31\n" +
"\n" +
"\n" +
"### baseFuel\n" +
"@@GAUGE_NAME_FUEL_BASE@@\\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections\n" +
"\n" +
"### afr_type\n" +
"PID dTime\n" +
"\n" +
"### speedToRpmRatio\n" +
"s2rpm\n" +
"\n" +
"### afr_typet\n" +
"\n" +
"\n" +
"### vehicleSpeedKph\n" +
"\n" +
"\n" +
"### isForcedInduction\n" +
"Does the vehicle have a turbo or supercharger?\n" +
"\n" +
"### enableFan1WithAc\n" +
"Turn on this fan when AC is on.\n" +
"\n", getConfigValueConsumer.getMdContent());
}
@Test(expected = MaybeSemicolonWasMissedException.class)
public void generateSuspiciousTsInfo() {
String test = "struct total\n" +
"uint8_t hello;\"unit\", 1, 0, 0, 100, 0\n" +
"end_struct\n";
ReaderStateImpl state = new ReaderStateImpl();
@Test
public void generateSuspiciousTsInfo() {
assertThrows(MaybeSemicolonWasMissedException.class, () -> {
String test = "struct total\n" +
"uint8_t hello;\"unit\", 1, 0, 0, 100, 0\n" +
"end_struct\n";
ReaderStateImpl state = new ReaderStateImpl();
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
}
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
});
}
}

View File

@ -3,7 +3,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.GetOutputValueConsumer;
import com.rusefi.util.LazyFile;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.output.HashUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.JavaSensorsConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -7,9 +7,11 @@ import com.rusefi.output.DataLogConsumer;
import com.rusefi.output.GaugeConsumer;
import com.rusefi.output.OutputsSectionConsumer;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class OutputsTest {
@Test
@ -35,15 +37,17 @@ public class OutputsTest {
assertEquals(expectedLegacy, runOriginalImplementation(test, state).getContent());
}
@Test(expected = BitState.TooManyBitsInARow.class)
@Test
public void tooManyBits() {
assertThrows(BitState.TooManyBitsInARow.class, () -> {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 40; i++)
sb.append("bit b" + i + "\n");
sb.append("bit b" + i + "\n");
String test = "struct total\n" +
sb +
"end_struct\n";
sb +
"end_struct\n";
runOriginalImplementation(test);
});
}
private static OutputsSectionConsumer runOriginalImplementation(String test) {
@ -191,18 +195,21 @@ public class OutputsTest {
"\ttriggerSimulatorPins3 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\\nSee also directSelfStimulation which is different. 3\"\n", tsProjectConsumer.getSettingContextHelpForUnitTest());
}
@Test(expected = IllegalStateException.class)
@Test
public void nameDuplicate() {
assertThrows(IllegalStateException.class, () -> {
System.out.println("run");
String test = "struct total\n" +
"float afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint8_t afr_type;123;\"ms\", 1, 0, 0, 3000, 0\n" +
"end_struct\n";
"float afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint8_t afr_type;123;\"ms\", 1, 0, 0, 3000, 0\n" +
"end_struct\n";
String expectedLegacy = "afr_type = scalar, F32, 0, \"ms\", 1, 0\n" +
"afr_type = scalar, U08, 0, \"ms\", 1, 0\n" +
"; total TS size = 1\n";
"afr_type = scalar, U08, 0, \"ms\", 1, 0\n" +
"; total TS size = 1\n";
assertEquals(expectedLegacy, runOriginalImplementation(test).getContent());
});
}
@Test

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import com.rusefi.ReaderStateImpl;
import com.rusefi.util.LazyFile;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class SdCardFieldsGeneratorTest {
@Test
@ -99,4 +99,4 @@ public class SdCardFieldsGeneratorTest {
state.readBufferedReader(input, consumer);
assertEquals(expectedOutput, consumer.getBody());
}
}
}

View File

@ -4,7 +4,7 @@ import com.rusefi.ReaderStateImpl;
import com.rusefi.output.BaseCHeaderConsumer;
import com.rusefi.output.JavaFieldsConsumer;
import com.rusefi.output.TSProjectConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.VariableRegistry;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringReader;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.VariableRegistry;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Arrays;

View File

@ -1,8 +1,8 @@
package com.rusefi;
import com.rusefi.enum_reader.Value;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import java.io.IOException;
import java.io.StringReader;
@ -11,8 +11,7 @@ import java.util.List;
import java.util.Map;
import static com.rusefi.EnumsReader.isKeyValueLine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class EnumToStringTest {
public static EnumToString process(EnumsReader enumsReader) {
@ -204,28 +203,31 @@ public class EnumToStringTest {
}
}
@Test(expected = IllegalStateException.class)
@Test
public void testWithInputOutOfOrder() throws IOException {
assertThrows(IllegalStateException.class, () -> {
final StringReader reader = new StringReader(
"typedef enum {\n" +
"\tGPIO_UNASSIGNED = XXXX,\n" +
"}brain_pin_e; // hello");
"typedef enum {\n" +
"\tGPIO_UNASSIGNED = XXXX,\n" +
"}brain_pin_e; // hello");
VariableRegistry registry = new VariableRegistry();
registry.readPrependValues(new StringReader("#define XXXX 12"));
EnumsReader enumsReader = new EnumsReader().read(reader);
for (Map.Entry<String /*enum name*/, EnumsReader.EnumState> e : enumsReader.getEnums().entrySet()) {
String java = ToJavaEnum.generate(registry, e.getKey(), e.getValue());
assertEquals("package com.rusefi.enums;\n" +
"//auto-generated by ToJavaEnum.java\n" +
"\n" +
"\n" +
"\n" +
"public enum brain_pin_e {\n" +
"\tGPIO_UNASSIGNED,\n" +
"}\n", java);
String java = ToJavaEnum.generate(registry, e.getKey(), e.getValue());
assertEquals("package com.rusefi.enums;\n" +
"//auto-generated by ToJavaEnum.java\n" +
"\n" +
"\n" +
"\n" +
"public enum brain_pin_e {\n" +
"\tGPIO_UNASSIGNED,\n" +
"}\n", java);
}
});
}

View File

@ -1,9 +1,9 @@
package com.rusefi.util.test;
import com.rusefi.util.LazyFileImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class LazyFileTest {
@Test

View File

@ -1,12 +1,11 @@
package rusefi;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;
public class GccMapReaderTest {
private static final String BSS = "bss";