Closed RomanLangrehr closed 9 years ago
Trust me, I just added the allDirectionAdditionsTest() method (and didn't modified the other methods). I don't know why the git compare tool totally fails here.
I don't know why the git compare tool totally fails here.
You changed the order of the methods. Do you perhaps still use the formatter cleanup tool (see #76)?
Anyway, here is a more readable diff with the original method order:
--- /tmp/git-difftool.5y5zF/left/src/final2/subtests/DirectionTest.java
+++ /tmp/git-difftool.5y5zF/right/src/final2/subtests/DirectionTest.java
@@ -15,6 +15,7 @@
*
* @author Annika Berger
* @author Joshua Gleitze
+ * @author Roman Langrehr
*/
public class DirectionTest extends LangtonSubtest {
@@ -99,6 +100,484 @@
}
/**
+ * Tests if the addition of {@code 45}, {@code 90}, {@code 270} and {@code 315} works on all Directions ({@code N},
+ * {@code NE}, {@code E}, {@code SE}, {@code S}, {@code SW}, {@code W} and {@code NW}).<br />
+ * <br />
+ * The colors {@code 0}, {@code 1}, {@code 2} and {@code 3} are used to make the rotations about {@code 45},
+ * {@code 90}, {@code 270} and {@code 315} degree.<br />
+ * <br />
+ * The ants looking {@code N} and {@code S} are created immediately on the playing field, the other ants are created
+ * like that:<br />
+ * (x is the cell, the ant will enter in the next move) <br />
+ * <br />
+ * {@code NE}:<br />
+ * {@code 00x}<br />
+ * {@code 000}<br />
+ * {@code 0A0}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ * {@code E}:<br />
+ * {@code 000}<br />
+ * {@code 01x}<br />
+ * {@code 0A0}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ * {@code SE}:<br />
+ * {@code 0a0}<br />
+ * {@code 030}<br />
+ * {@code 00x}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ * {@code SW}:<br />
+ * {@code 0a0}<br />
+ * {@code 000}<br />
+ * {@code x00}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ * {@code W}:<br />
+ * {@code 000}<br />
+ * {@code x20}<br />
+ * {@code 0A0}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ * {@code NW}:<br />
+ * {@code x00}<br />
+ * {@code 030}<br />
+ * {@code 0A0}<br />
+ * moves to the bring the ant in the starting position: {@code 1}<br />
+ * <br />
+ */
+ @Test
+ public void allDirectionAdditionsTest() {
+ String rule = "rule=45-90-270-315-45";
+
+ // Addition to N
+
+ inputFile = new String[] {
+ "000",
+ "000",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("NO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "010",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("O")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "020",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("W")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "030",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("NW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to NE
+
+ inputFile = new String[] {
+ "000",
+ "000",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("O")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "001",
+ "000",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "002",
+ "000",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "003",
+ "000",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("N")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to E
+
+ inputFile = new String[] {
+ "000",
+ "010",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "011",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("S")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "012",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("N")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "013",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to SE
+
+ inputFile = new String[] {
+ "0a0",
+ "030",
+ "000"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("S")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "030",
+ "001"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "030",
+ "002"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "030",
+ "003"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("O")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to S
+
+ inputFile = new String[] {
+ "0a0",
+ "000",
+ "000"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("SW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "010",
+ "000"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("W")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "020",
+ "000"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("O")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "030",
+ "000"
+ };
+ runs = new Run[] {
+ move(1),
+ new ExactRun("direction a", is("SO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to SW
+
+ inputFile = new String[] {
+ "0a0",
+ "000",
+ "000"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("W")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "000",
+ "100"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "000",
+ "200"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "0a0",
+ "000",
+ "300"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("S")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to W
+
+ inputFile = new String[] {
+ "000",
+ "020",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "120",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("N")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "220",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("S")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "000",
+ "320",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ // Addition to NW
+
+ inputFile = new String[] {
+ "000",
+ "030",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("N")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "100",
+ "030",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("NO")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "200",
+ "030",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("SW")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ inputFile = new String[] {
+ "300",
+ "030",
+ "0A0"
+ };
+ runs = new Run[] {
+ move(1), // to bring the ant in the starting position
+ move(1),
+ new ExactRun("direction a", is("W")),
+ quit()
+ };
+ sessionTest(runs, Input.getFile(inputFile), rule);
+
+ }
+
+ /**
* Asserts that {@code direction} works on a test file with all ant and cell types. Please refer to
* {@link LangtonSubtest#ALL_TYPES_BOARD} for a detailed description of what is supposed to happen.
*/
Well documented. lgtm.
Very well documented and meaningful test. Thanks for the clearer diff! @pcworld regarding diff and git, there's still much for us to learn from you :)
Do you think it would make sense to assert that the ant is not only facing in the right direction, but will actually enter the cell it is expected to in the next move?
Merging in favour of #172. Please don't stop the discussion.
@jGleitz I think that's a good idea and a good place to check this. I'll add this test.
Fixes #174