mirror of https://github.com/rusefi/rusefi.git
refactoring
This commit is contained in:
parent
1d3e5c6d83
commit
753598483f
|
@ -191,8 +191,12 @@ public class ReaderState {
|
|||
consumer.handleEndStruct(this, structure);
|
||||
}
|
||||
|
||||
public void readBufferedReader(String inputString, ConfigurationConsumer... consumers) throws IOException {
|
||||
readBufferedReader(new BufferedReader(new StringReader(inputString)), Arrays.asList(consumers));
|
||||
public void readBufferedReader(String inputString, ConfigurationConsumer... consumers) {
|
||||
try {
|
||||
readBufferedReader(new BufferedReader(new StringReader(inputString)), Arrays.asList(consumers));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void readBufferedReader(BufferedReader definitionReader, List<ConfigurationConsumer> consumers) throws IOException {
|
||||
|
|
|
@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class BitParsingTest {
|
||||
@Test
|
||||
public void testBitParser() throws IOException {
|
||||
public void testBitParser() {
|
||||
ReaderState state = new ReaderState();
|
||||
|
||||
String inputString = "struct pid_s\n" +
|
||||
|
|
|
@ -10,7 +10,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class ConfigFieldParserIssue1057Test {
|
||||
@Test
|
||||
public void testBitsPadding() throws IOException {
|
||||
public void testBitsPadding() {
|
||||
ReaderState state = new ReaderState();
|
||||
JavaFieldsConsumer javaFieldsConsumer = new TestJavaFieldsConsumer(state);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFloatMsAlias() throws IOException {
|
||||
public void testFloatMsAlias() {
|
||||
String test = "struct pid_s\n" +
|
||||
"floatms_t afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"percent_t afr_typet;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
|
@ -63,7 +63,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSameFieldTwice() throws IOException {
|
||||
public void testSameFieldTwice() {
|
||||
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" +
|
||||
|
@ -76,7 +76,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEnum() throws IOException {
|
||||
public void testCustomEnum() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ego_sensor_e_enum \"BPSX\", \"Innovate\", \"14Point7\"\n" +
|
||||
"custom ego_sensor_e 1 bits, S08, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
|
||||
|
@ -95,7 +95,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testShortForm() throws IOException {
|
||||
public void testShortForm() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ego_sensor_e_enum \"BPSX\"\n" +
|
||||
"custom ego_sensor_e 1 bits, S08, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
|
||||
|
@ -114,7 +114,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test2byteCustomEnum() throws IOException {
|
||||
public void test2byteCustomEnum() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ego_sensor_e_enum \"BPSX\", \"Innovate\", \"14Point7\"\n" +
|
||||
"custom ego_sensor_e2 2 bits, S16, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
|
||||
|
@ -133,7 +133,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test4byteCustomEnum() throws IOException {
|
||||
public void test4byteCustomEnum() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ego_sensor_e_enum \"BPSX\", \"Innovate\", \"14Point7\"\n" +
|
||||
"custom ego_sensor_e4 4 bits, S32, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
|
||||
|
@ -150,7 +150,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void alignFourByteTypes() throws IOException {
|
||||
public void alignFourByteTypes() {
|
||||
// we expect padding before each 4 byte field
|
||||
String test = "struct pid_s\n" +
|
||||
"\tint16_t periodMs1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
|
@ -171,7 +171,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void alignArray6() throws IOException {
|
||||
public void alignArray6() {
|
||||
// we expect padding before each 4 byte field
|
||||
String test = "struct vr_threshold_s\n" +
|
||||
"\tuint8_t pin;\n" +
|
||||
|
@ -191,7 +191,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void manyStartAreNotMultiplication() throws IOException {
|
||||
public void manyStartAreNotMultiplication() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ERROR_BUFFER_SIZE \"***\"\n" +
|
||||
"end_struct\n" +
|
||||
|
@ -200,7 +200,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void invalidDefine() throws IOException {
|
||||
public void invalidDefine() {
|
||||
String test = "struct pid_s\n" +
|
||||
VariableRegistry.DEFINE + " show show_Hellen121vag_presets true\n" +
|
||||
"end_struct\n" +
|
||||
|
@ -209,7 +209,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void multiplicationInDefine() throws IOException {
|
||||
public void multiplicationInDefine() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ERROR_BUFFER_SIZE 120\n" +
|
||||
"#define ERROR_BUFFER_COUNT 120\n" +
|
||||
|
@ -226,7 +226,7 @@ public class ConfigFieldParserTest {
|
|||
"#define RESULT 14400\n", state.variableRegistry.getDefinesSection());
|
||||
}
|
||||
@Test
|
||||
public void expressionInMultiplier() throws IOException {
|
||||
public void expressionInMultiplier() {
|
||||
String test = "struct pid_s\n" +
|
||||
"\tint16_t autoscale periodMs;PID dTime;\"ms\", {1/10}, 0, 0, 3000, 0\n" +
|
||||
"\tint16_t periodMs2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
|
@ -247,7 +247,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void useCustomType() throws IOException {
|
||||
public void useCustomType() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ERROR_BUFFER_SIZE 120\n" +
|
||||
|
@ -267,7 +267,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDefineChar() throws IOException {
|
||||
public void testDefineChar() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test =
|
||||
"#define SD_r 'r'\n" +
|
||||
|
@ -282,7 +282,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDefine() throws IOException {
|
||||
public void testDefine() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test =
|
||||
"#define ERROR_BUFFER_SIZE 120\n" +
|
||||
|
@ -299,7 +299,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFsioVisible() throws IOException {
|
||||
public void testFsioVisible() {
|
||||
{
|
||||
ReaderState state = new ReaderState();
|
||||
ConfigField cf = ConfigField.parse(state, "int fsio_visible field");
|
||||
|
@ -349,7 +349,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test2byteOffset() throws IOException {
|
||||
public void test2byteOffset() {
|
||||
String test = "struct_no_prefix pid_s\n" +
|
||||
"\tint8_t byte1\n" +
|
||||
"\tint16_t short\n" +
|
||||
|
@ -534,7 +534,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testArrayOfOne() throws IOException {
|
||||
public void testArrayOfOne() {
|
||||
String test = "struct pid_s\n" +
|
||||
"#define ERROR_BUFFER_SIZE 1\n" +
|
||||
"int[ERROR_BUFFER_SIZE iterate] autoscale field;;\"ratio\", 0.01, 0, 0, 650, 0\n" +
|
||||
|
@ -559,7 +559,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testStructAfterByte() throws IOException {
|
||||
public void testStructAfterByte() {
|
||||
String test = "struct struct_s\n" +
|
||||
"\tint int2\n" +
|
||||
"end_struct\n" +
|
||||
|
@ -604,7 +604,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void justTwoBytes() throws IOException {
|
||||
public void justTwoBytes() {
|
||||
String test =
|
||||
"struct_no_prefix pid_s\n" +
|
||||
"\tint8_t byte1\n" +
|
||||
|
@ -699,7 +699,7 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testStructTooltips() throws IOException {
|
||||
public void testStructTooltips() {
|
||||
String test = "struct total\n" +
|
||||
"struct pid_s\n" +
|
||||
"floatms_t afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
|
|
|
@ -10,7 +10,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class FragmentDialogConsumerTest {
|
||||
@Test
|
||||
public void generateFragmentDialog() throws IOException {
|
||||
public void generateFragmentDialog() {
|
||||
ReaderState state = new ReaderState();
|
||||
String outputChannels = "" +
|
||||
"\n" +
|
||||
|
|
|
@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class GetConfigValueConsumerTest {
|
||||
@Test
|
||||
public void testStructArrayAndCharArgument() throws IOException {
|
||||
public void testStructArrayAndCharArgument() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test = "struct total\n" +
|
||||
"custom lua_script_t 200 string, ASCII, @OFFSET@, 200\n" +
|
||||
|
@ -43,7 +43,7 @@ public class GetConfigValueConsumerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateEmbeddedStruct() throws IOException {
|
||||
public void generateEmbeddedStruct() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test = "struct total\n" +
|
||||
"struct_no_prefix thermistor_conf_s @brief Thermistor known values\n" +
|
||||
|
@ -85,7 +85,7 @@ public class GetConfigValueConsumerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateGetConfig() throws IOException {
|
||||
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" +
|
||||
|
@ -189,7 +189,7 @@ public class GetConfigValueConsumerTest {
|
|||
}
|
||||
|
||||
@Test(expected = MaybeSemicolorWasMissedException.class)
|
||||
public void generateSuspiciousTsInfo() throws IOException {
|
||||
public void generateSuspiciousTsInfo() {
|
||||
String test = "struct total\n" +
|
||||
"uint8_t hello;\"unit\", 1, 0, 0, 100, 0\n" +
|
||||
"end_struct\n";
|
||||
|
|
|
@ -10,7 +10,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class JavaSensorsConsumerTest {
|
||||
@Test
|
||||
public void generateJavaSensors() throws IOException {
|
||||
public void generateJavaSensors() {
|
||||
ReaderState state = new ReaderState();
|
||||
state.variableRegistry.register("PACK_MULT_PERCENT", 100);
|
||||
state.variableRegistry.register("GAUGE_NAME_RPM", "\"hello\"");
|
||||
|
@ -44,7 +44,7 @@ public class JavaSensorsConsumerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void bitAtTheEndBug() throws IOException {
|
||||
public void bitAtTheEndBug() {
|
||||
ReaderState state = new ReaderState();
|
||||
String outputChannels =
|
||||
"struct_no_prefix output_channels_s\n" +
|
||||
|
|
|
@ -38,7 +38,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test(expected = BitState.TooManyBitsInARow.class)
|
||||
public void tooManyBits() throws IOException {
|
||||
public void tooManyBits() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 40; i++)
|
||||
sb.append("bit b" + i + "\n");
|
||||
|
@ -52,7 +52,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateDataLog() throws IOException {
|
||||
public void generateDataLog() {
|
||||
String test = "struct total\n" +
|
||||
"bit issue_294_31,\"si_example\",\"nada_example\"\n" +
|
||||
"uint8_t[2 iterate] autoscale knock;;\"\",1, 0, 0, 0, 0\n" +
|
||||
|
@ -89,7 +89,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateDataLogMultiLineCommentWithQuotes() throws IOException {
|
||||
public void generateDataLogMultiLineCommentWithQuotes() {
|
||||
String test = "#define GAUGE_NAME_FUEL_BASE \"fuel: base mass\"\n" +
|
||||
"struct total\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, 0, 0, 0, 0\n" +
|
||||
|
@ -109,7 +109,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateGetOutputs() throws IOException {
|
||||
public void generateGetOutputs() {
|
||||
String test = "struct_no_prefix ts_outputs_s\n" +
|
||||
"bit issue_294_31,\"si_example\",\"nada_example\"\n" +
|
||||
"bit enableFan1WithAc;+Turn on this fan when AC is on.\n" +
|
||||
|
@ -134,7 +134,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sensorStruct() throws IOException {
|
||||
public void sensorStruct() {
|
||||
String test = "struct total\n" +
|
||||
" struct pid_status_s\n" +
|
||||
" \tfloat iTerm;;\"v\", 1, 0, -10000, 10000, 4\n" +
|
||||
|
@ -164,7 +164,7 @@ public class OutputsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLongIterate() throws IOException {
|
||||
public void testLongIterate() {
|
||||
ReaderState state = new ReaderState();
|
||||
String test = "struct total\n" +
|
||||
"\tint[3 iterate] triggerSimulatorPins;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.\n" +
|
||||
|
|
|
@ -22,7 +22,7 @@ public class TSProjectConsumerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void conditionalField() throws IOException {
|
||||
public void conditionalField() {
|
||||
String test = "struct pid_s\n" +
|
||||
"custom afr_table_t 4x4 array, U08, @OFFSET@, [4x4],\"deg\",\t {1/10}, 0, 0, 25.0, 1 \n" +
|
||||
"#if LAMBDA\n" +
|
||||
|
|
Loading…
Reference in New Issue