From 4664234acaee6ec7f2fc936a0c883e61f43aab62 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 10 Sep 2023 11:17:26 -0400 Subject: [PATCH] only:weird results --- .../pinout/PinoutLogicHellen112_17_Test.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicHellen112_17_Test.java diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicHellen112_17_Test.java b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicHellen112_17_Test.java new file mode 100644 index 0000000000..03154a7169 --- /dev/null +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicHellen112_17_Test.java @@ -0,0 +1,65 @@ +package com.rusefi.pinout; + +import com.rusefi.ReaderStateImpl; +import com.rusefi.newparse.DefinitionsState; +import org.junit.Test; + +import java.io.*; + +import static com.rusefi.test.ConfigDefinitionTest.FIRMWARE; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; + +public class PinoutLogicHellen112_17_Test { + @Test + public void testRealFiled() throws IOException { + // a bit nasty, do we have similar anywhere else already? + FileSystemBoardInputsReaderImpl.PREFIX = FIRMWARE + File.separator; + + ReaderStateImpl state = new ReaderStateImpl(); + state.getEnumsReader().read(new FileReader(FileSystemBoardInputsReaderImpl.PREFIX + "controllers/algo/rusefi_hw_stm32_enums.h")); + state.getEnumsReader().read(new FileReader(FileSystemBoardInputsReaderImpl.PREFIX + "controllers/algo/rusefi_hw_adc_enums.h")); + + assertFalse(state.getEnumsReader().getEnums().isEmpty()); + + + DefinitionsState definitionState = state.getEnumsReader().parseState; + + StringWriter boardNamesTestWriter = new StringWriter(); + + StringWriter outputsTestWriter = new StringWriter(); + + PinoutLogic logic = new PinoutLogic(new FileSystemBoardInputsReaderImpl(FileSystemBoardInputsReaderImpl.PREFIX + "config/boards/hellen/hellen-112-17/") { + @Override + public Writer getBoardNamesWriter() { + return boardNamesTestWriter; + } + + @Override + public Writer getOutputsWriter() { + return outputsTestWriter; + } + }); + + logic.registerBoardSpecificPinNames(state.getVariableRegistry(), definitionState, state.getEnumsReader()); + + + assertEquals("//DO NOT EDIT MANUALLY, let automation work hard.\n" + + "\n" + + "// auto-generated by PinoutLogic.java based on ..\\..\\firmware\\config\\boards\\hellen\\hellen-112-17\\connectors\\main.yaml\n" + + "#include \"pch.h\"\n" + + "\n" + + "// see comments at declaration in pin_repository.h\n" + + "const char * getBoardSpecificPinName(brain_pin_e brainPin) {\n" + + "\tswitch(brainPin) {\n" + + "\t\tcase Gpio::E12: return \"231 Cam\";\n" + + "\t\tcase Gpio::E13: return \"232 VSS\";\n" + + "\t\tcase Gpio::E6: return \"Main Relay\";\n" + + "\t\tdefault: return nullptr;\n" + + "\t}\n" + + "\treturn nullptr;\n" + + "}\n", boardNamesTestWriter.toString()); + + } + +}