2020-02-15 14:17:23 +00:00
|
|
|
package edu.kit.informatik;
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
|
|
class MainTest {
|
|
|
|
@Test
|
|
|
|
void basics() throws IOException {
|
|
|
|
cmpInOut("basics_input.txt", "basics_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void exampleInteraction() throws IOException {
|
|
|
|
cmpInOut("example1input.txt", "example1ONLYoutput.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void limits() throws IOException {
|
|
|
|
cmpInOut("example2input.txt", "example2output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void loopy() throws IOException {
|
|
|
|
cmpInOut("loopyinput.txt", "loopyoutput.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void hitMeBabyOneMoreTime() throws IOException {
|
|
|
|
cmpInOut("stophittingyourself_input.txt", "stophittingyourself_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz1() throws IOException {
|
|
|
|
cmpInOut("fuzz1_input.txt", "fuzz1_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz2() throws IOException {
|
|
|
|
cmpInOut("fuzz2_input.txt", "fuzz2_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz3() throws IOException {
|
|
|
|
cmpInOut("fuzz3_input.txt", "fuzz3_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz4() throws IOException {
|
|
|
|
cmpInOut("fuzz4_input.txt", "fuzz4_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz5() throws IOException {
|
|
|
|
cmpInOut("fuzz5_input.txt", "fuzz5_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz6() throws IOException {
|
|
|
|
cmpInOut("fuzz6_input.txt", "fuzz6_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-16 18:21:07 +00:00
|
|
|
@Test
|
|
|
|
void fuzz7() throws IOException {
|
|
|
|
cmpInOut("fuzz7_input.txt", "fuzz7_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-16 18:42:12 +00:00
|
|
|
@Test
|
|
|
|
void fuzz8() throws IOException {
|
|
|
|
cmpInOut("fuzz8_input.txt", "fuzz8_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-17 19:39:30 +00:00
|
|
|
@Test
|
|
|
|
void fuzz9() throws IOException {
|
|
|
|
cmpInOut("fuzz9_input.txt", "fuzz9_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-17 08:46:00 +00:00
|
|
|
@Test
|
|
|
|
void fuzz10() throws IOException {
|
|
|
|
cmpInOut("fuzz10_input.txt", "fuzz10_output.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void fuzz11() throws IOException {
|
|
|
|
cmpInOut("fuzz11_input.txt", "fuzz11_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-18 13:19:45 +00:00
|
|
|
@Test
|
|
|
|
void testCoverage() throws IOException {
|
|
|
|
cmpInOut("testcoverage_input.txt", "testcoverage_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-25 13:58:14 +00:00
|
|
|
@Test
|
|
|
|
void oneLengthDerailEdgecase() throws IOException {
|
|
|
|
cmpInOut("train_one_length_input.txt", "train_one_length_output.txt");
|
|
|
|
}
|
|
|
|
|
2020-02-15 14:17:23 +00:00
|
|
|
private void cmpInOut(String in, String out) throws IOException {
|
|
|
|
System.setIn(new ByteArrayInputStream(readFile(in)));
|
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
System.setOut(new PrintStream(output));
|
|
|
|
Terminal.reload();
|
|
|
|
Main.main(null);
|
|
|
|
String expected = new String(readFile(out));
|
|
|
|
assertEquals(expected, output.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
private byte[] readFile(String name) throws IOException {
|
|
|
|
File file = new File(name);
|
|
|
|
return Files.readAllBytes(file.toPath());
|
|
|
|
}
|
|
|
|
}
|