mirror of https://github.com/rusefi/rusefi.git
only:more LiveDataProcessor coverage
This commit is contained in:
parent
01d93eb3f9
commit
3699755046
|
@ -19,6 +19,8 @@ public class LiveDataProcessor {
|
|||
private final static String enumContentFileName = "console/binary/generated/live_data_ids.h";
|
||||
|
||||
private final static String tsOutputsDestination = "console/binary/";
|
||||
public static final String DATA_LOG_FILE_NAME = tsOutputsDestination + File.separator + "generated/data_logs.ini";
|
||||
public static final String OUTPUTS_SECTION_FILE_NAME = tsOutputsDestination + File.separator + "generated/output_channels.ini";
|
||||
|
||||
private final ReaderProvider readerProvider;
|
||||
private final LazyFile.LazyFileFactory fileFactory;
|
||||
|
@ -108,10 +110,10 @@ public class LiveDataProcessor {
|
|||
public int handleYaml(Map<String, Object> data) throws IOException {
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer();
|
||||
|
||||
OutputsSectionConsumer outputsSections = new OutputsSectionConsumer(tsOutputsDestination + File.separator + "generated/output_channels.ini",
|
||||
OutputsSectionConsumer outputsSections = new OutputsSectionConsumer(OUTPUTS_SECTION_FILE_NAME,
|
||||
fileFactory);
|
||||
|
||||
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(tsOutputsDestination + File.separator + "generated/data_logs.ini", fileFactory);
|
||||
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(DATA_LOG_FILE_NAME, fileFactory);
|
||||
|
||||
SdCardFieldsContent sdCardFieldsConsumer = new SdCardFieldsContent();
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.rusefi.ldmp;
|
||||
|
||||
import com.rusefi.ReaderProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class LiveDataProcessorTest {
|
||||
@Test
|
||||
public void testTwoSections() throws IOException {
|
||||
String testYaml = "Usages:\n" +
|
||||
"# output_channels always goes first at least because it has protocol version at well-known offset\n" +
|
||||
" - name: output_channels\n" +
|
||||
" java: TsOutputs.java\n" +
|
||||
" folder: console/binary\n" +
|
||||
" cppFileName: status_loop\n" +
|
||||
" constexpr: \"engine->outputChannels\"\n";
|
||||
|
||||
|
||||
Map<String, Object> data = LiveDataProcessor.getStringObjectMap(new StringReader(testYaml));
|
||||
|
||||
TestFileCaptor captor = new TestFileCaptor();
|
||||
LiveDataProcessor liveDataProcessor = new LiveDataProcessor("test", new ReaderProvider() {
|
||||
@Override
|
||||
public Reader read(String fileName) {
|
||||
System.out.println("read " + fileName);
|
||||
return new StringReader("struct_no_prefix wideband_state_s\n" +
|
||||
"\tuint16_t tempC;WBO: Temperature;\"C\", 1, 0, 500, 1000, 0\n" +
|
||||
"\tuint16_t esr;WBO: ESR;\"ohm\", 1, 0, 0, 10000, 0\n" +
|
||||
"end_struct");
|
||||
}
|
||||
}, captor);
|
||||
liveDataProcessor.handleYaml(data);
|
||||
assertEquals(7, captor.fileCapture.size());
|
||||
|
||||
assertEquals("tempC = scalar, U16, 0, \"C\", 1, 0\n" +
|
||||
"esr = scalar, U16, 2, \"ohm\", 1, 0\n" +
|
||||
"; total TS size = 4\n", captor.fileCapture.get(LiveDataProcessor.OUTPUTS_SECTION_FILE_NAME).sb.toString());
|
||||
|
||||
assertEquals("entry = tempC, \"WBO: Temperature\", int, \"%d\"\n" +
|
||||
"entry = esr, \"WBO: ESR\", int, \"%d\"\n", captor.fileCapture.get(LiveDataProcessor.DATA_LOG_FILE_NAME).sb.toString());
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue