Config generation handles padding after packed booleans (bits) wrong #1057
everything should start with a unit test
This commit is contained in:
parent
ae73ee3d65
commit
d7c131dba0
|
@ -46,6 +46,8 @@ public class ReaderState {
|
|||
}
|
||||
|
||||
ConfigField bitField = new ConfigField(state, bitName, comment, null, BOOLEAN_T, 0, null, false, false, null, -1);
|
||||
if (state.stack.isEmpty())
|
||||
throw new IllegalStateException("Parent structure expected");
|
||||
state.stack.peek().addBoth(bitField);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.rusefi.test;
|
||||
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.output.JavaFieldsConsumer;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ConfigFieldParserIssue1057Test {
|
||||
@Test
|
||||
public void testBitsPadding() throws IOException {
|
||||
ReaderState state = new ReaderState();
|
||||
JavaFieldsConsumer javaFieldsConsumer = new JavaFieldsConsumer(state) {
|
||||
@Override
|
||||
public void startFile() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFile() {
|
||||
}
|
||||
};
|
||||
|
||||
String inputString = "struct pid_s\nbit activateAuxPid1;\n" +
|
||||
"int fieldName;\n" +
|
||||
"end_struct\n";
|
||||
BufferedReader reader = new BufferedReader(new StringReader(inputString));
|
||||
|
||||
|
||||
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
|
||||
|
||||
assertEquals("\tpublic static final Field ACTIVATEAUXPID1 = Field.create(\"ACTIVATEAUXPID1\", 0, FieldType.BIT, 0);\n" +
|
||||
"\tpublic static final Field FIELDNAME = Field.create(\"FIELDNAME\", 4, FieldType.INT);\n",
|
||||
javaFieldsConsumer.getJavaFieldsWriter());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue