diff options
author | Pacien TRAN-GIRARD | 2016-02-21 14:00:10 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-02-21 14:00:10 +0100 |
commit | 54e3de1cea374695922c54455c70c1c550bdad73 (patch) | |
tree | 25f890a35c2ead1b584cd3afe7772347a75b6911 /test/ch | |
parent | 89b4b288f24ca11e4fa718b75a3a07a3597c8b84 (diff) | |
download | xblast-54e3de1cea374695922c54455c70c1c550bdad73.tar.gz |
Revert "Import first part unit tests"
This reverts commit df1880840db7bd8229d46118fb6d8508ecda61a1.
Diffstat (limited to 'test/ch')
-rw-r--r-- | test/ch/epfl/xblast/CellTest.java | 68 | ||||
-rw-r--r-- | test/ch/epfl/xblast/DirectionTest.java | 41 | ||||
-rw-r--r-- | test/ch/epfl/xblast/SubCellTest.java | 60 | ||||
-rw-r--r-- | test/ch/epfl/xblast/namecheck/NameCheck01.java | 49 |
4 files changed, 0 insertions, 218 deletions
diff --git a/test/ch/epfl/xblast/CellTest.java b/test/ch/epfl/xblast/CellTest.java deleted file mode 100644 index ba8becc..0000000 --- a/test/ch/epfl/xblast/CellTest.java +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | package ch.epfl.xblast; | ||
2 | |||
3 | import static org.junit.Assert.assertEquals; | ||
4 | import static org.junit.Assert.assertFalse; | ||
5 | |||
6 | import org.junit.Test; | ||
7 | |||
8 | public class CellTest { | ||
9 | @Test | ||
10 | public void rowMajorIndexCorrespondsToOrder() { | ||
11 | int i = 0; | ||
12 | for (Cell c: Cell.ROW_MAJOR_ORDER) | ||
13 | assertEquals(i++, c.rowMajorIndex()); | ||
14 | assertEquals(Cell.COUNT, i); | ||
15 | } | ||
16 | |||
17 | @Test | ||
18 | public void spiralOrderContainsAllCells() { | ||
19 | assertEquals(Cell.COUNT, Cell.SPIRAL_ORDER.size()); | ||
20 | |||
21 | boolean[] cellSeen = new boolean[Cell.COUNT]; | ||
22 | for (Cell c: Cell.SPIRAL_ORDER) { | ||
23 | assertFalse(cellSeen[c.rowMajorIndex()]); | ||
24 | cellSeen[c.rowMajorIndex()] = true; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | @Test | ||
29 | public void spiralOrderNeighborsAreSpatialNeighbors() { | ||
30 | Cell pred = Cell.SPIRAL_ORDER.get(0); | ||
31 | for (Cell c: Cell.SPIRAL_ORDER.subList(1, Cell.SPIRAL_ORDER.size())) { | ||
32 | int areNeighborsCount = 0; | ||
33 | for (Direction d: Direction.values()) { | ||
34 | if (pred.equals(c.neighbor(d))) | ||
35 | areNeighborsCount += 1; | ||
36 | } | ||
37 | assertEquals(1, areNeighborsCount); | ||
38 | pred = c; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | @Test | ||
43 | public void constructorCorrectlyNormalizesCoordinates() { | ||
44 | for (int i = -2; i <= 2; ++i) { | ||
45 | Cell c = new Cell(14 + 15 * i, 12 + 13 * i); | ||
46 | assertEquals(14, c.x()); | ||
47 | assertEquals(12, c.y()); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | @Test | ||
52 | public void neighborsOfOriginAreCorrect() { | ||
53 | Cell c = new Cell(0, 0); | ||
54 | assertEquals(new Cell( 0, 12), c.neighbor(Direction.N)); | ||
55 | assertEquals(new Cell( 1, 0), c.neighbor(Direction.E)); | ||
56 | assertEquals(new Cell( 0, 1), c.neighbor(Direction.S)); | ||
57 | assertEquals(new Cell(14, 0), c.neighbor(Direction.W)); | ||
58 | } | ||
59 | |||
60 | @Test | ||
61 | public void oppositeNeighborOfNeighborIsThis() { | ||
62 | for (Cell c: Cell.ROW_MAJOR_ORDER) { | ||
63 | for (Direction d: Direction.values()) { | ||
64 | assertEquals(c, c.neighbor(d).neighbor(d.opposite())); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | } | ||
diff --git a/test/ch/epfl/xblast/DirectionTest.java b/test/ch/epfl/xblast/DirectionTest.java deleted file mode 100644 index a2ac9cd..0000000 --- a/test/ch/epfl/xblast/DirectionTest.java +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | package ch.epfl.xblast; | ||
2 | |||
3 | import static org.junit.Assert.assertEquals; | ||
4 | import static org.junit.Assert.assertFalse; | ||
5 | import static org.junit.Assert.assertTrue; | ||
6 | |||
7 | import org.junit.Test; | ||
8 | |||
9 | public class DirectionTest { | ||
10 | @Test | ||
11 | public void oppositeOfOppositeIsIdentity() { | ||
12 | for (Direction d: Direction.values()) | ||
13 | assertEquals(d, d.opposite().opposite()); | ||
14 | } | ||
15 | |||
16 | @Test | ||
17 | public void oppositeIsTwoStepsAway() { | ||
18 | for (Direction d: Direction.values()) | ||
19 | assertEquals(2, Math.abs(d.ordinal() - d.opposite().ordinal())); | ||
20 | } | ||
21 | |||
22 | @Test | ||
23 | public void isHorizontalIsCorrect() { | ||
24 | assertFalse(Direction.N.isHorizontal()); | ||
25 | assertTrue(Direction.E.isHorizontal()); | ||
26 | assertFalse(Direction.S.isHorizontal()); | ||
27 | assertTrue(Direction.W.isHorizontal()); | ||
28 | } | ||
29 | |||
30 | @Test | ||
31 | public void isParallelIsTrueOnlyForOppositeAndSelf() { | ||
32 | for (Direction d1: Direction.values()) { | ||
33 | for (Direction d2: Direction.values()) { | ||
34 | if (d1 == d2 || d1 == d2.opposite()) | ||
35 | assertTrue(d1.isParallelTo(d2)); | ||
36 | else | ||
37 | assertFalse(d1.isParallelTo(d2)); | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | } | ||
diff --git a/test/ch/epfl/xblast/SubCellTest.java b/test/ch/epfl/xblast/SubCellTest.java deleted file mode 100644 index 1c79791..0000000 --- a/test/ch/epfl/xblast/SubCellTest.java +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | package ch.epfl.xblast; | ||
2 | |||
3 | import static org.junit.Assert.assertEquals; | ||
4 | import static org.junit.Assert.assertTrue; | ||
5 | |||
6 | import org.junit.Test; | ||
7 | |||
8 | public class SubCellTest { | ||
9 | @Test | ||
10 | public void centralSubCellOfKnowCellIsCorrect() { | ||
11 | SubCell c = SubCell.centralSubCellOf(new Cell(2, 1)); | ||
12 | assertEquals(40, c.x()); | ||
13 | assertEquals(24, c.y()); | ||
14 | } | ||
15 | |||
16 | @Test | ||
17 | public void centralSubCellIsCentral() { | ||
18 | for (Cell c: Cell.ROW_MAJOR_ORDER) | ||
19 | assertTrue(SubCell.centralSubCellOf(c).isCentral()); | ||
20 | } | ||
21 | |||
22 | @Test | ||
23 | public void distanceToCentralOfCentralIsZero() { | ||
24 | for (Cell c: Cell.ROW_MAJOR_ORDER) | ||
25 | assertEquals(0, SubCell.centralSubCellOf(c).distanceToCentral()); | ||
26 | } | ||
27 | |||
28 | @Test | ||
29 | public void constructorCorrectlyNormalizesCoordinates() { | ||
30 | for (int i = -2; i <= 2; ++i) { | ||
31 | SubCell c = new SubCell(239 + 240 * i, 207 + 208 * i); | ||
32 | assertEquals(239, c.x()); | ||
33 | assertEquals(207, c.y()); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | @Test | ||
38 | public void distanceToCentralOfOriginIsCorrect() { | ||
39 | SubCell s = new SubCell(0, 0); | ||
40 | assertEquals(16, s.distanceToCentral()); | ||
41 | } | ||
42 | |||
43 | @Test | ||
44 | public void neighborsOfOriginAreCorrect() { | ||
45 | SubCell c = new SubCell(0, 0); | ||
46 | assertEquals(new SubCell( 0, 207), c.neighbor(Direction.N)); | ||
47 | assertEquals(new SubCell( 1, 0), c.neighbor(Direction.E)); | ||
48 | assertEquals(new SubCell( 0, 1), c.neighbor(Direction.S)); | ||
49 | assertEquals(new SubCell(239, 0), c.neighbor(Direction.W)); | ||
50 | } | ||
51 | |||
52 | @Test | ||
53 | public void containingCellOfCentralsNeighborIsCorrect() { | ||
54 | for (Cell c: Cell.ROW_MAJOR_ORDER) { | ||
55 | SubCell s = SubCell.centralSubCellOf(c); | ||
56 | for (Direction d: Direction.values()) | ||
57 | assertEquals(c, s.neighbor(d).containingCell()); | ||
58 | } | ||
59 | } | ||
60 | } | ||
diff --git a/test/ch/epfl/xblast/namecheck/NameCheck01.java b/test/ch/epfl/xblast/namecheck/NameCheck01.java deleted file mode 100644 index 278d85b..0000000 --- a/test/ch/epfl/xblast/namecheck/NameCheck01.java +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | package ch.epfl.xblast.namecheck; | ||
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | import ch.epfl.xblast.Cell; | ||
6 | import ch.epfl.xblast.Direction; | ||
7 | import ch.epfl.xblast.SubCell; | ||
8 | |||
9 | /** | ||
10 | * Classe abstraite utilisant tous les éléments de l'étape 1, pour essayer de | ||
11 | * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est | ||
12 | * pas un test unitaire, et n'a pas pour but d'être exécuté! | ||
13 | */ | ||
14 | |||
15 | abstract class NameCheck01 { | ||
16 | void checkDirection() { | ||
17 | Direction d = Direction.N; | ||
18 | d = Direction.E; | ||
19 | d = Direction.S; | ||
20 | d = Direction.W; | ||
21 | if (d.isHorizontal() || d.isParallelTo(d)) | ||
22 | d = d.opposite(); | ||
23 | } | ||
24 | |||
25 | void checkCell() { | ||
26 | int c = Cell.COLUMNS; | ||
27 | int r = Cell.ROWS; | ||
28 | int t = Cell.COUNT; | ||
29 | List<Cell> l = Cell.ROW_MAJOR_ORDER; | ||
30 | l.get(c + r + t); | ||
31 | l = Cell.SPIRAL_ORDER; | ||
32 | l.get(c + r + t); | ||
33 | Cell d = new Cell(c, r); | ||
34 | c = d.x() + d.y() + d.rowMajorIndex(); | ||
35 | d = d.neighbor(Direction.N); | ||
36 | } | ||
37 | |||
38 | void checkSubCell() { | ||
39 | SubCell c = SubCell.centralSubCellOf(new Cell(0,0)); | ||
40 | c = new SubCell(0, 0); | ||
41 | int t = c.x() + c.y() + c.distanceToCentral(); | ||
42 | if (t < 10 && c.isCentral()) | ||
43 | c = c.neighbor(Direction.N); | ||
44 | else { | ||
45 | Cell cc = c.containingCell(); | ||
46 | System.out.println(cc); | ||
47 | } | ||
48 | } | ||
49 | } | ||