From fa7d33ac19b952d785f9721f9410064b5442e7f7 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 10 Jun 2023 20:27:16 -0400 Subject: [PATCH] only: extracting & fixing test --- .../test/GetOutputValueConsumerTest.java | 48 +++++++++++++++++++ .../java/com/rusefi/test/OutputsTest.java | 39 --------------- 2 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 java_tools/configuration_definition/src/test/java/com/rusefi/test/GetOutputValueConsumerTest.java diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/GetOutputValueConsumerTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/GetOutputValueConsumerTest.java new file mode 100644 index 0000000000..5d7f6c4d5c --- /dev/null +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/GetOutputValueConsumerTest.java @@ -0,0 +1,48 @@ +package com.rusefi.test; + +import com.rusefi.ReaderStateImpl; +import com.rusefi.output.GetOutputValueConsumer; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class GetOutputValueConsumerTest { + @Test + public void generateGetOutputs() { + String test = "struct_no_prefix ts_outputs_s\n" + + "bit issue_294_31,\"si_example\",\"nada_example\"\n" + + "bit enableFan1WithAc;+Turn on this fan when AC is on.\n" + + "int hwChannel;\n" + + "end_struct\n"; + ReaderStateImpl state = new ReaderStateImpl(); + + GetOutputValueConsumer outputValueConsumer = new GetOutputValueConsumer(null); + outputValueConsumer.conditional = "EFI_BOOST_CONTROL"; + state.readBufferedReader(test, (outputValueConsumer)); + assertEquals( + "// generated by GetOutputValueConsumer.java\n" + + "#include \"pch.h\"\n" + + "#include \"value_lookup.h\"\n" + + "float getOutputValueByName(const char *name) {\n" + + "\tint hash = djb2lowerCase(name);\n" + + "\tswitch(hash) {\n" + + "// issue_294_31\n" + + "#if EFI_BOOST_CONTROL\n" + + "\t\tcase -1571463185:\n" + + "\t\t\treturn engine->outputChannels.issue_294_31;\n" + + "#endif\n" + + "// enableFan1WithAc\n" + + "#if EFI_BOOST_CONTROL\n" + + "\t\tcase -298185774:\n" + + "\t\t\treturn engine->outputChannels.enableFan1WithAc;\n" + + "#endif\n" + + "// hwChannel\n" + + "#if EFI_BOOST_CONTROL\n" + + "\t\tcase -709106787:\n" + + "\t\t\treturn engine->outputChannels.hwChannel;\n" + + "#endif\n" + + "\t}\n" + + "\treturn EFI_ERROR_CODE;\n" + + "}\n", outputValueConsumer.getContent()); + } +} diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/OutputsTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/OutputsTest.java index 87ae93b3ae..848081a6d9 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/test/OutputsTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/OutputsTest.java @@ -137,45 +137,6 @@ public class OutputsTest { } - @Test - public void generateGetOutputs() { - String test = "struct_no_prefix ts_outputs_s\n" + - "bit issue_294_31,\"si_example\",\"nada_example\"\n" + - "bit enableFan1WithAc;+Turn on this fan when AC is on.\n" + - "int hwChannel;\n" + - "end_struct\n"; - ReaderStateImpl state = new ReaderStateImpl(); - - GetOutputValueConsumer outputValueConsumer = new GetOutputValueConsumer(null); - outputValueConsumer.conditional = "EFI_BOOST_CONTROL"; - state.readBufferedReader(test, (outputValueConsumer)); - assertEquals( - "// generated by GetConfigValueConsumer.java\n" + - "#include \"pch.h\"\n" + - "#include \"value_lookup.h\"\n" + - "float getOutputValueByName(const char *name) {\n" + - "\tint hash = djb2lowerCase(name);\n" + - "\tswitch(hash) {\n" + - "// issue_294_31\n" + - "#if EFI_BOOST_CONTROL\n" + - "\t\tcase -1571463185:\n" + - "\t\t\treturn engine->outputChannels.issue_294_31;\n" + - "#endif\n" + - "// enableFan1WithAc\n" + - "#if EFI_BOOST_CONTROL\n" + - "\t\tcase -298185774:\n" + - "\t\t\treturn engine->outputChannels.enableFan1WithAc;\n" + - "#endif\n" + - "// hwChannel\n" + - "#if EFI_BOOST_CONTROL\n" + - "\t\tcase -709106787:\n" + - "\t\t\treturn engine->outputChannels.hwChannel;\n" + - "#endif\n" + - "\t}\n" + - "\treturn EFI_ERROR_CODE;\n" + - "}\n", outputValueConsumer.getContent()); - } - @Test public void sensorStruct() { String test = "struct total\n" +