PID auto tune unit test
This commit is contained in:
parent
dd2f17a332
commit
30b7cc6080
|
@ -1,6 +1,6 @@
|
||||||
// auto-generated from.\controllers/algo/rusefi_enums.h
|
// auto-generated from.\controllers/algo/rusefi_enums.h
|
||||||
// by enum2string.jar tool
|
// by enum2string.jar tool
|
||||||
// on Thu Nov 22 18:48:26 EST 2018
|
// on Thu Nov 22 20:05:41 EST 2018
|
||||||
// see also gen_config_and_enums.bat
|
// see also gen_config_and_enums.bat
|
||||||
|
|
||||||
|
|
||||||
|
@ -950,6 +950,8 @@ const char *getPidAutoTune_Peak(PidAutoTune_Peak value){
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case MAXIMUM:
|
case MAXIMUM:
|
||||||
return "MAXIMUM";
|
return "MAXIMUM";
|
||||||
|
case MINIMUM:
|
||||||
|
return "MINIMUM";
|
||||||
case NOT_A_PEAK:
|
case NOT_A_PEAK:
|
||||||
return "NOT_A_PEAK";
|
return "NOT_A_PEAK";
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="junit">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../../java_console/lib/junit.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<target name="compile">
|
<target name="compile">
|
||||||
<mkdir dir="build/classes"/>
|
<mkdir dir="build/classes"/>
|
||||||
<javac destdir="build/classes" classpath="lib/junit.jar:lib/annotations.jar">
|
<javac destdir="build/classes" classpath="../../java_console/lib/junit.jar:lib/annotations.jar">
|
||||||
<src path="src"/>
|
<src path="src"/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="junit" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class EnumToString {
|
||||||
reader = new BufferedReader(new FileReader(inFileName));
|
reader = new BufferedReader(new FileReader(inFileName));
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
line = line.replaceAll("\\s+", "");
|
line = removeSpaces(line);
|
||||||
|
|
||||||
if (line.startsWith("typedefenum{")) {
|
if (line.startsWith("typedefenum{")) {
|
||||||
System.out.println("Entering enum");
|
System.out.println("Entering enum");
|
||||||
|
@ -87,7 +87,7 @@ public class EnumToString {
|
||||||
} else {
|
} else {
|
||||||
line = line.replaceAll("//.+", "");
|
line = line.replaceAll("//.+", "");
|
||||||
if (isInsideEnum) {
|
if (isInsideEnum) {
|
||||||
if (line.matches("[a-zA-Z_$][a-zA-Z\\d_$]*[=a-zA-Z\\d_*]*,?")) {
|
if (isKeyValueLine(line)) {
|
||||||
line = line.replace(",", "");
|
line = line.replace(",", "");
|
||||||
int index = line.indexOf('=');
|
int index = line.indexOf('=');
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
@ -100,6 +100,14 @@ public class EnumToString {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String removeSpaces(String line) {
|
||||||
|
return line.replaceAll("\\s+", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isKeyValueLine(String line) {
|
||||||
|
return removeSpaces(line).matches("[a-zA-Z_$][a-zA-Z\\d_$]*[=-a-zA-Z\\d_*]*,?");
|
||||||
|
}
|
||||||
|
|
||||||
private static String makeCode(String enumName) {
|
private static String makeCode(String enumName) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(getMethodSignature(enumName) + "{\r\n");
|
sb.append(getMethodSignature(enumName) + "{\r\n");
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static com.rusefi.EnumToString.isKeyValueLine;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class EnumToStringTest {
|
||||||
|
@Test
|
||||||
|
public void testParseLine() {
|
||||||
|
assertTrue(isKeyValueLine("MIN"));
|
||||||
|
assertTrue(isKeyValueLine("MIN = 2,"));
|
||||||
|
assertTrue(isKeyValueLine("MIN = -3,"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue