only:more LiveDataProcessor coverage

This commit is contained in:
rusefillc 2023-12-06 12:23:04 -05:00
parent 3699755046
commit 997a72e184
1 changed files with 38 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import static org.junit.Assert.assertEquals;
public class LiveDataProcessorTest {
@Test
public void testTwoSections() throws IOException {
public void testUnnamedSection() 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" +
@ -44,4 +44,41 @@ public class LiveDataProcessorTest {
"entry = esr, \"WBO: ESR\", int, \"%d\"\n", captor.fileCapture.get(LiveDataProcessor.DATA_LOG_FILE_NAME).sb.toString());
}
@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" +
" output_name: [ \"wb1\", \"wb2\" ]\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());
}
}