Skip to content

Commit

Permalink
debug is set to idle mode, but none of the debug fields show anything #…
Browse files Browse the repository at this point in the history
…4335

a mess with quotes and new lines
  • Loading branch information
rusefillc committed Jul 8, 2022
1 parent eb3f93a commit bbb869c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Binary file modified java_tools/ConfigDefinition.jar
Binary file not shown.
Expand Up @@ -367,11 +367,12 @@ public int getDigits() {
return Integer.parseInt(tokens[5].trim());
}

// see testUnquote
public static String unquote(String token) {
int length = token.length();
if (length < 2)
return token;
if (token.charAt(0) == '\"')
if (token.charAt(0) == '\"' && token.charAt(token.length() - 1) == '\"')
return token.substring(1, length - 1);
return token;
}
Expand Down
Expand Up @@ -753,4 +753,14 @@ public void testStructTooltips() throws IOException {
"\tpid_isForcedInduction = \"Does the vehicle have a turbo or supercharger?\"\n" +
"\tpid_enableFan1WithAc = \"Turn on this fan when AC is on.\"\n", tsProjectConsumer.getSettingContextHelp().toString());
}

@Test
public void testUnquote() {
assertEquals("x", ConfigField.unquote("\"x\""));
// leave broken opening-only quote!
assertEquals("\"x", ConfigField.unquote("\"x"));
// this does not look great let's document this corner case for now
assertEquals("x\"\n" +
"\"y", ConfigField.unquote("\"x\"\n\"y\""));
}
}
Expand Up @@ -101,7 +101,7 @@ public void generateDataLog() throws IOException {
state.variableRegistry.register("GAUGE_NAME_FUEL_BASE", "hello");

DataLogConsumer dataLogConsumer = new DataLogConsumer(null);
state.readBufferedReader(test, (dataLogConsumer));
state.readBufferedReader(test, dataLogConsumer);
assertEquals(
"entry = issue_294_31, \"issue_294_31\", int, \"%d\"\n" +
"entry = knock1, \"knock 1\", int, \"%d\"\n" +
Expand All @@ -120,17 +120,19 @@ public void generateDataLog() throws IOException {

@Test
public void generateDataLogMultiLineCommentWithQuotes() throws IOException {
String test = "struct total\n" +
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" +
"\tuint16_t autoscale baseFuel2;\"line1\\nline2\";\"mg\",1, 0, 0, 0, 0\n" +
"end_struct\n";
ReaderState state = new ReaderState();
state.variableRegistry.register("GAUGE_NAME_FUEL_BASE", "hello");

DataLogConsumer dataLogConsumer = new DataLogConsumer(null);
state.readBufferedReader(test, (dataLogConsumer));
state.readBufferedReader(test, dataLogConsumer);

assertEquals("\"fuel: base mass\"", state.variableRegistry.get("GAUGE_NAME_FUEL_BASE"));
assertEquals(
"entry = baseFuel, \"hello\", int, \"%d\"\n" +
"entry = baseFuel, \"fuel: base mass\", int, \"%d\"\n" +
"entry = baseFuel2, \"line1\", int, \"%d\"\n"
, dataLogConsumer.getContent());

Expand Down

0 comments on commit bbb869c

Please sign in to comment.