Do not test precise error message wording

This commit is contained in:
Arne Keller 2020-03-12 09:18:58 +01:00
parent 0b913bf943
commit 0eac34a6c7

View File

@ -60,8 +60,23 @@ class MainTest {
System.setOut(new PrintStream(output)); System.setOut(new PrintStream(output));
Terminal.reload(); Terminal.reload();
Main.main(null); Main.main(null);
String outputStr = output.toString();
String expected = new String(readFile(out)); String expected = new String(readFile(out));
String[] expectedLines = expected.split(System.lineSeparator());
String[] actualLines = outputStr.split(System.lineSeparator());
if (expectedLines.length != actualLines.length) {
assertEquals(expected, output.toString()); assertEquals(expected, output.toString());
} else {
for (int i = 0; i < actualLines.length; i++) {
if (expectedLines[i].startsWith("<e") || expectedLines[i].startsWith("Error, ")) {
if (!actualLines[i].startsWith("Error, ")) {
assertEquals(expected, output.toString());
}
} else if (!expectedLines[i].equals(actualLines[i])) {
assertEquals(expected, output.toString());
}
}
}
} }
private byte[] readFile(String name) throws IOException { private byte[] readFile(String name) throws IOException {