From 30b7cc6080806412e519eb2c60ade7e985b8af21 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 22 Nov 2018 20:09:53 -0500 Subject: [PATCH] PID auto tune unit test --- .../controllers/algo/auto_generated_enums.cpp | 4 +++- java_tools/enum2string.jar | Bin 5284 -> 6320 bytes .../enum_to_string/.idea/libraries/junit.xml | 9 +++++++++ java_tools/enum_to_string/build.xml | 2 +- java_tools/enum_to_string/enum_to_string.iml | 4 ++-- .../src/com/rusefi/EnumToString.java | 12 ++++++++++-- .../src/com/rusefi/EnumToStringTest.java | 15 +++++++++++++++ 7 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 java_tools/enum_to_string/.idea/libraries/junit.xml create mode 100644 java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 8bd9252f04..be457c3770 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -1,6 +1,6 @@ // auto-generated from.\controllers/algo/rusefi_enums.h // 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 @@ -950,6 +950,8 @@ const char *getPidAutoTune_Peak(PidAutoTune_Peak value){ switch(value) { case MAXIMUM: return "MAXIMUM"; +case MINIMUM: + return "MINIMUM"; case NOT_A_PEAK: return "NOT_A_PEAK"; } diff --git a/java_tools/enum2string.jar b/java_tools/enum2string.jar index 3fd5a3dede32e1e922444587864a7fda75e04a2c..c9c79f78d990d7d2c40bb9d72edb4325092f4efc 100644 GIT binary patch literal 6320 zcmeHLX*iT^8y-tB3}p<1h$%~B>}$!s?@LI?IvBD5W`+EO=$M?hi9QU&v&v{onG*qNW1?XaRuo+yDc>-xd%+ z4KUC!QxVoN)D+zz0073{p|k+}F7)0TkDlONc*5?6?CzgX0~JFZO$}2s5d%$wxGK6% zF$iEwc?X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9WzThG6z>c;t{|S{ zKJYMA-voXvj8L?BUKQ=u-PLy8R;%hhJ~rZkZfSh9F_XWHVOf)*O~FXIuAPo5(KHpG z8lKO zUj;YS!lqoYlvHG~lYjNO-RQVfOkQDU+WpYF*;S7bjWdGkxzlT{ue8fptx&bMO5Qc3?QD+*^{=>rd;S@-kDSA2a-YX7#)M z_r)iukKYrle|8*XSl{cQ-G5OZ4;()etslm}$Gaca+*@a8{$l*^gzG + + + + + + + + \ No newline at end of file diff --git a/java_tools/enum_to_string/build.xml b/java_tools/enum_to_string/build.xml index 36abf41433..df8bac5b35 100644 --- a/java_tools/enum_to_string/build.xml +++ b/java_tools/enum_to_string/build.xml @@ -6,7 +6,7 @@ - + diff --git a/java_tools/enum_to_string/enum_to_string.iml b/java_tools/enum_to_string/enum_to_string.iml index d5c0743275..2d6846244d 100644 --- a/java_tools/enum_to_string/enum_to_string.iml +++ b/java_tools/enum_to_string/enum_to_string.iml @@ -7,6 +7,6 @@ + - - + \ No newline at end of file diff --git a/java_tools/enum_to_string/src/com/rusefi/EnumToString.java b/java_tools/enum_to_string/src/com/rusefi/EnumToString.java index d2ea69c12d..c43ea2b89f 100644 --- a/java_tools/enum_to_string/src/com/rusefi/EnumToString.java +++ b/java_tools/enum_to_string/src/com/rusefi/EnumToString.java @@ -72,7 +72,7 @@ public class EnumToString { reader = new BufferedReader(new FileReader(inFileName)); String line; while ((line = reader.readLine()) != null) { - line = line.replaceAll("\\s+", ""); + line = removeSpaces(line); if (line.startsWith("typedefenum{")) { System.out.println("Entering enum"); @@ -87,7 +87,7 @@ public class EnumToString { } else { line = line.replaceAll("//.+", ""); if (isInsideEnum) { - if (line.matches("[a-zA-Z_$][a-zA-Z\\d_$]*[=a-zA-Z\\d_*]*,?")) { + if (isKeyValueLine(line)) { line = line.replace(",", ""); int index = line.indexOf('='); 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) { StringBuilder sb = new StringBuilder(); sb.append(getMethodSignature(enumName) + "{\r\n"); diff --git a/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java b/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java new file mode 100644 index 0000000000..d225258089 --- /dev/null +++ b/java_tools/enum_to_string/src/com/rusefi/EnumToStringTest.java @@ -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,")); + } +}