only:junit5

This commit is contained in:
rusefillc 2023-12-15 11:29:56 -05:00
parent 9644a01d10
commit c2b1ba7e01
23 changed files with 335 additions and 319 deletions

View File

@ -2,8 +2,8 @@ package com.rusefi.pinout;
import com.rusefi.ReaderStateImpl;
import com.rusefi.newparse.DefinitionsState;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.*;
@ -13,7 +13,7 @@ import static junit.framework.TestCase.assertFalse;
public class PinoutLogicHellen112_17_Test {
@Test
@Ignore // this was only useful while figuring out the problem
@Disabled // this was only useful while figuring out the problem
public void testRealFiled() throws IOException {
// a bit nasty, do we have similar anywhere else already?
FileSystemBoardInputsReaderImpl.PREFIX = FIRMWARE + File.separator;

View File

@ -3,7 +3,7 @@ package com.rusefi.pinout;
import com.rusefi.ReaderStateImpl;
import com.rusefi.enum_reader.Value;
import com.rusefi.newparse.DefinitionsState;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.util.Arrays;

View File

@ -2,7 +2,7 @@ package com.rusefi.pinout;
import com.rusefi.EnumsReader;
import com.rusefi.enum_reader.Value;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;

View File

@ -4,7 +4,7 @@ import com.rusefi.ReaderStateImpl;
import com.rusefi.TsFileContent;
import com.rusefi.output.TSProjectConsumer;
import com.rusefi.util.Output;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.*;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.output.BaseCHeaderConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,7 +3,7 @@ package com.rusefi.test;
import com.rusefi.EnumsReader;
import com.rusefi.VariableRegistry;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileReader;

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.JavaFieldsConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,9 +3,9 @@ package com.rusefi.test;
import com.rusefi.*;
import com.rusefi.output.*;
import com.rusefi.parse.TypesHelper;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Andrey Belomutskiy, (c) 2013-2020
@ -22,7 +22,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getArraySizes().length, 1);
assertEquals(cf.getArraySizes()[0], 8);
assertEquals(cf.getSize(null), 8);
assertFalse("isIterate", cf.isIterate());
assertFalse(cf.isIterate(), "isIterate");
}
}
@ -36,7 +36,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getArraySizes()[0], 8);
assertEquals(cf.getArraySizes()[1], 16);
assertEquals(cf.getSize(null), 128);
assertFalse("isIterate", cf.isIterate());
assertFalse(cf.isIterate(), "isIterate");
}
}
@ -68,8 +68,9 @@ public class ConfigFieldParserTest {
"; total TS size = 12\n", tsProjectConsumer.getContent());
}
@Test(expected = IllegalStateException.class)
@Test
public void testSameFieldTwice() {
assertThrows(IllegalStateException.class, () -> {
String test = "struct pid_s\n" +
"int afr_type1;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"int afr_type2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
@ -79,6 +80,7 @@ public class ConfigFieldParserTest {
BaseCHeaderConsumer consumer = new BaseCHeaderConsumer();
state.readBufferedReader(test, consumer);
});
}
@Test
@ -205,13 +207,15 @@ public class ConfigFieldParserTest {
new ReaderStateImpl().readBufferedReader(test);
}
@Test(expected = IllegalStateException.class)
@Test
public void invalidDefine() {
assertThrows(IllegalStateException.class, () -> {
String test = "struct pid_s\n" +
VariableRegistry.DEFINE + " show show_Hellen121vag_presets true\n" +
"end_struct\n" +
"";
new ReaderStateImpl().readBufferedReader(test);
});
}
@Test
@ -364,7 +368,7 @@ public class ConfigFieldParserTest {
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int field");
assertEquals(cf.getType(), "int");
assertEquals("Name", cf.getName(), "field");
assertEquals(cf.getName(), "field", "Unexpected Field Name");
}
{
@ -671,7 +675,7 @@ public class ConfigFieldParserTest {
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int field");
assertEquals(cf.getType(), "int");
assertEquals("Name", cf.getName(), "field");
assertEquals(cf.getName(), "field", "Name");
}
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int_4 fie4_ld");
@ -682,7 +686,7 @@ public class ConfigFieldParserTest {
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int_8 fi_eld;comm_;ts,1,1");
assertEquals(cf.getType(), "int_8");
assertEquals(cf.getName(), "fi_eld");
assertEquals("Comment", cf.getComment(), "comm_");
assertEquals(cf.getComment(), "comm_", "Comment");
assertEquals(cf.getTsInfo(), "ts,1,1");
}
{
@ -690,7 +694,7 @@ public class ConfigFieldParserTest {
assertEquals(cf.getType(), "int");
assertEquals(cf.getArraySizes().length, 1);
assertEquals(cf.getArraySizes()[0], 3);
assertTrue("isIterate", cf.isIterate());
assertTrue(cf.isIterate(), "isIterate");
}
{
ConfigFieldImpl cf = ConfigFieldImpl.parse(state, "int16_t crankingRpm;This,. value controls what RPM values we consider 'cranking' (any RPM below 'crankingRpm')\\nAnything above 'crankingRpm' would be 'running'");

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.EnumsReader;
import com.rusefi.ReaderStateImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.FiringOrderTSLogic;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class FiringOrderTSLogicTest {
@Test

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.FragmentDialogConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -3,9 +3,11 @@ package com.rusefi.test;
import com.rusefi.MaybeSemicolonWasMissedException;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.GetConfigValueConsumer;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class GetConfigValueConsumerTest {
@Test
@ -260,8 +262,9 @@ public class GetConfigValueConsumerTest {
"\n", getConfigValueConsumer.getMdContent());
}
@Test(expected = MaybeSemicolonWasMissedException.class)
@Test
public void generateSuspiciousTsInfo() {
assertThrows(MaybeSemicolonWasMissedException.class, () -> {
String test = "struct total\n" +
"uint8_t hello;\"unit\", 1, 0, 0, 100, 0\n" +
"end_struct\n";
@ -270,5 +273,6 @@ public class GetConfigValueConsumerTest {
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
state.readBufferedReader(test, getConfigValueConsumer);
});
}
}

View File

@ -3,7 +3,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.GetOutputValueConsumer;
import com.rusefi.util.LazyFile;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.output.HashUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -2,7 +2,7 @@ package com.rusefi.test;
import com.rusefi.ReaderStateImpl;
import com.rusefi.output.JavaSensorsConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -7,9 +7,11 @@ import com.rusefi.output.DataLogConsumer;
import com.rusefi.output.GaugeConsumer;
import com.rusefi.output.OutputsSectionConsumer;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class OutputsTest {
@Test
@ -35,8 +37,9 @@ public class OutputsTest {
assertEquals(expectedLegacy, runOriginalImplementation(test, state).getContent());
}
@Test(expected = BitState.TooManyBitsInARow.class)
@Test
public void tooManyBits() {
assertThrows(BitState.TooManyBitsInARow.class, () -> {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 40; i++)
sb.append("bit b" + i + "\n");
@ -44,6 +47,7 @@ public class OutputsTest {
sb +
"end_struct\n";
runOriginalImplementation(test);
});
}
private static OutputsSectionConsumer runOriginalImplementation(String test) {
@ -191,8 +195,10 @@ public class OutputsTest {
"\ttriggerSimulatorPins3 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\\nSee also directSelfStimulation which is different. 3\"\n", tsProjectConsumer.getSettingContextHelpForUnitTest());
}
@Test(expected = IllegalStateException.class)
@Test
public void nameDuplicate() {
assertThrows(IllegalStateException.class, () -> {
System.out.println("run");
String test = "struct total\n" +
"float afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"uint8_t afr_type;123;\"ms\", 1, 0, 0, 3000, 0\n" +
@ -203,6 +209,7 @@ public class OutputsTest {
"afr_type = scalar, U08, 0, \"ms\", 1, 0\n" +
"; total TS size = 1\n";
assertEquals(expectedLegacy, runOriginalImplementation(test).getContent());
});
}
@Test

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import com.rusefi.ReaderStateImpl;
import com.rusefi.util.LazyFile;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class SdCardFieldsGeneratorTest {
@Test

View File

@ -4,7 +4,7 @@ import com.rusefi.ReaderStateImpl;
import com.rusefi.output.BaseCHeaderConsumer;
import com.rusefi.output.JavaFieldsConsumer;
import com.rusefi.output.TSProjectConsumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.VariableRegistry;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringReader;

View File

@ -1,7 +1,7 @@
package com.rusefi.test;
import com.rusefi.VariableRegistry;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Arrays;

View File

@ -1,8 +1,8 @@
package com.rusefi;
import com.rusefi.enum_reader.Value;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import java.io.IOException;
import java.io.StringReader;
@ -11,8 +11,7 @@ import java.util.List;
import java.util.Map;
import static com.rusefi.EnumsReader.isKeyValueLine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class EnumToStringTest {
public static EnumToString process(EnumsReader enumsReader) {
@ -204,8 +203,9 @@ public class EnumToStringTest {
}
}
@Test(expected = IllegalStateException.class)
@Test
public void testWithInputOutOfOrder() throws IOException {
assertThrows(IllegalStateException.class, () -> {
final StringReader reader = new StringReader(
"typedef enum {\n" +
"\tGPIO_UNASSIGNED = XXXX,\n" +
@ -226,6 +226,8 @@ public class EnumToStringTest {
"\tGPIO_UNASSIGNED,\n" +
"}\n", java);
}
});
}

View File

@ -1,9 +1,9 @@
package com.rusefi.util.test;
import com.rusefi.util.LazyFileImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class LazyFileTest {
@Test

View File

@ -1,12 +1,11 @@
package rusefi;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;
public class GccMapReaderTest {
private static final String BSS = "bss";