Add switch derailing test

This commit is contained in:
Arne Keller 2020-03-08 11:31:07 +01:00
parent a9348c4bdc
commit cbac7fb00f
3 changed files with 49 additions and 0 deletions

View File

@ -139,6 +139,11 @@ class MainTest {
cmpInOut("test13_input.txt", "test13_output.txt"); cmpInOut("test13_input.txt", "test13_output.txt");
} }
@Test
void switchDerailsAllTrains() throws IOException {
cmpInOut("switch_derails_all_trains_input.txt", "switch_derails_all_trains_output.txt");
}
private void cmpInOut(String in, String out) throws IOException { private void cmpInOut(String in, String out) throws IOException {
System.setIn(new ByteArrayInputStream(readFile(in))); System.setIn(new ByteArrayInputStream(readFile(in)));
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();

View File

@ -0,0 +1,21 @@
add switch (0,0) -> (5,0),(0,5)
add track (-2,0) -> (0,0)
add track (7,0) -> (5,0)
add track (0,7) -> (0,5)
create train-set T1 Alpha 1 true true
create train-set T1 Beta 1 true true
create train-set T1 Delta 1 true true
create train-set T1 Gamma 1 true true
add train 1 T1-Alpha
add train 2 T1-Beta
add train 3 T1-Delta
add train 4 T1-Gamma
set switch 1 position (5,0)
put train 1 at (-1,0) in direction 1,0
put train 2 at (6,0) in direction -1,0
put train 3 at (0,6) in direction 0,-1
put train 4 at (2,0) in direction 1,0
step 1
set switch 1 position (5,0)
step 0
exit

View File

@ -0,0 +1,23 @@
1
2
3
4
T1-Alpha
T1-Beta
T1-Delta
T1-Gamma
train-set T1-Alpha added to train 1
train-set T1-Beta added to train 2
train-set T1-Delta added to train 3
train-set T1-Gamma added to train 4
OK
OK
OK
OK
OK
Train 1 at (0,0)
Train 2 at (5,0)
Train 3 at (0,5)
Train 4 at (3,0)
OK
OK