diff options
Diffstat (limited to 'test/ch/epfl')
-rw-r--r-- | test/ch/epfl/xblast/ListsTest.java | 32 | ||||
-rw-r--r-- | test/ch/epfl/xblast/namecheck/NameCheck02.java | 60 | ||||
-rw-r--r-- | test/ch/epfl/xblast/server/BlockTest.java | 35 | ||||
-rw-r--r-- | test/ch/epfl/xblast/server/BoardTest.java | 137 |
4 files changed, 264 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java new file mode 100644 index 0000000..6a98b3f --- /dev/null +++ b/test/ch/epfl/xblast/ListsTest.java | |||
@@ -0,0 +1,32 @@ | |||
1 | package ch.epfl.xblast; | ||
2 | |||
3 | import java.util.List; | ||
4 | import java.util.Arrays; | ||
5 | import static org.junit.Assert.*; | ||
6 | import org.junit.Test; | ||
7 | |||
8 | /** | ||
9 | * @author Pacien TRAN-GIRARD (261948) | ||
10 | * @author Timothée FLOURE (257420) | ||
11 | */ | ||
12 | public class ListsTest { | ||
13 | @Test(expected=IllegalArgumentException.class) | ||
14 | public void isEmptyListThrowingException() { | ||
15 | List<Integer> sampleList = Arrays.asList(); | ||
16 | Lists.<Integer>mirrored(sampleList); | ||
17 | } | ||
18 | |||
19 | @Test(expected=IllegalArgumentException.class) | ||
20 | public void isNullListThrowingException() { | ||
21 | List<Integer> sampleList = Arrays.asList(); | ||
22 | Lists.<Integer>mirrored(sampleList); | ||
23 | } | ||
24 | |||
25 | @Test | ||
26 | public void isListMirrored() { | ||
27 | List<Integer> sampleList = Arrays.asList(1,2,3,4,5); | ||
28 | List<Integer> expected = Arrays.asList(1,2,3,4,5,4,3,2,1); | ||
29 | |||
30 | assertEquals(expected, Lists.<Integer>mirrored(sampleList)); | ||
31 | } | ||
32 | } | ||
diff --git a/test/ch/epfl/xblast/namecheck/NameCheck02.java b/test/ch/epfl/xblast/namecheck/NameCheck02.java new file mode 100644 index 0000000..978526e --- /dev/null +++ b/test/ch/epfl/xblast/namecheck/NameCheck02.java | |||
@@ -0,0 +1,60 @@ | |||
1 | package ch.epfl.xblast.namecheck; | ||
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | import ch.epfl.cs108.Sq; | ||
6 | import ch.epfl.xblast.Cell; | ||
7 | import ch.epfl.xblast.Lists; | ||
8 | import ch.epfl.xblast.server.Block; | ||
9 | import ch.epfl.xblast.server.Board; | ||
10 | import ch.epfl.xblast.server.Ticks; | ||
11 | |||
12 | /** | ||
13 | * Classe abstraite utilisant tous les éléments de l'étape 2, pour essayer de | ||
14 | * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est | ||
15 | * pas un test unitaire, et n'a pas pour but d'être exécuté! | ||
16 | */ | ||
17 | |||
18 | abstract class NameCheck02 { | ||
19 | void checkTicks() { | ||
20 | int x = Ticks.PLAYER_DYING_TICKS | ||
21 | + Ticks.PLAYER_INVULNERABLE_TICKS | ||
22 | + Ticks.BOMB_FUSE_TICKS | ||
23 | + Ticks.EXPLOSION_TICKS | ||
24 | + Ticks.WALL_CRUMBLING_TICKS | ||
25 | + Ticks.BONUS_DISAPPEARING_TICKS; | ||
26 | System.out.println(x); | ||
27 | } | ||
28 | |||
29 | void checkBlock() { | ||
30 | Block b = Block.FREE; | ||
31 | b = Block.INDESTRUCTIBLE_WALL; | ||
32 | b = Block.DESTRUCTIBLE_WALL; | ||
33 | b = Block.CRUMBLING_WALL; | ||
34 | boolean d = b.isFree() && b.canHostPlayer() && b.castsShadow(); | ||
35 | System.out.println(b + "/" + d); | ||
36 | } | ||
37 | |||
38 | void checkLists() { | ||
39 | List<Integer> l1 = null; | ||
40 | List<String> l2 = null; | ||
41 | List<List<String>> l3 = null; | ||
42 | List<Integer> l1m = Lists.<Integer>mirrored(l1); | ||
43 | List<String> l2m = Lists.<String>mirrored(l2); | ||
44 | List<List<String>> l3m = Lists.<List<String>>mirrored(l3); | ||
45 | System.out.println("" + l1m + l2m + l3m); | ||
46 | } | ||
47 | |||
48 | void checkBoard() { | ||
49 | List<List<Block>> q = null; | ||
50 | Board b = Board.ofQuadrantNWBlocksWalled(q); | ||
51 | b = Board.ofInnerBlocksWalled(q); | ||
52 | b = Board.ofRows(q); | ||
53 | List<Sq<Block>> cells = null; | ||
54 | b = new Board(cells); | ||
55 | Cell c = null; | ||
56 | Sq<Block> bs = b.blocksAt(c); | ||
57 | Block l = b.blockAt(c); | ||
58 | System.out.println(bs + "/" + l); | ||
59 | } | ||
60 | } | ||
diff --git a/test/ch/epfl/xblast/server/BlockTest.java b/test/ch/epfl/xblast/server/BlockTest.java new file mode 100644 index 0000000..bbe4376 --- /dev/null +++ b/test/ch/epfl/xblast/server/BlockTest.java | |||
@@ -0,0 +1,35 @@ | |||
1 | package ch.epfl.xblast.server; | ||
2 | |||
3 | import org.junit.Test; | ||
4 | |||
5 | import static org.junit.Assert.*; | ||
6 | |||
7 | /** | ||
8 | * @author Timothée FLOURE (257420) | ||
9 | * @author pacien TRAN-GIRARD (261948) | ||
10 | */ | ||
11 | public class BlockTest { | ||
12 | @Test | ||
13 | public void free() { | ||
14 | assertFalse(Block.INDESTRUCTIBLE_WALL.isFree()); | ||
15 | assertFalse(Block.DESTRUCTIBLE_WALL.isFree()); | ||
16 | assertFalse(Block.CRUMBLING_WALL.isFree()); | ||
17 | assertTrue(Block.FREE.isFree()); | ||
18 | } | ||
19 | |||
20 | @Test | ||
21 | public void canHostPlayer() { | ||
22 | assertFalse(Block.INDESTRUCTIBLE_WALL.canHostPlayer()); | ||
23 | assertFalse(Block.DESTRUCTIBLE_WALL.canHostPlayer()); | ||
24 | assertFalse(Block.CRUMBLING_WALL.canHostPlayer()); | ||
25 | assertTrue(Block.FREE.canHostPlayer()); | ||
26 | } | ||
27 | |||
28 | @Test | ||
29 | public void castSadhow() { | ||
30 | assertTrue(Block.INDESTRUCTIBLE_WALL.castsShadow()); | ||
31 | assertTrue(Block.DESTRUCTIBLE_WALL.castsShadow()); | ||
32 | assertTrue(Block.CRUMBLING_WALL.castsShadow()); | ||
33 | assertFalse(Block.FREE.castsShadow()); | ||
34 | } | ||
35 | } | ||
diff --git a/test/ch/epfl/xblast/server/BoardTest.java b/test/ch/epfl/xblast/server/BoardTest.java new file mode 100644 index 0000000..7868e70 --- /dev/null +++ b/test/ch/epfl/xblast/server/BoardTest.java | |||
@@ -0,0 +1,137 @@ | |||
1 | package ch.epfl.xblast.server; | ||
2 | |||
3 | import java.util.List; | ||
4 | import java.util.ArrayList; | ||
5 | import org.junit.Test; | ||
6 | import ch.epfl.cs108.Sq; | ||
7 | |||
8 | import static org.junit.Assert.*; | ||
9 | |||
10 | /** | ||
11 | * @author Timothée FLOURE (257420) | ||
12 | * @author Pacien TRAN-GIRARD (261948) | ||
13 | */ | ||
14 | public class BoardTest { | ||
15 | |||
16 | @Test(expected=IllegalArgumentException.class) | ||
17 | public void isBoardBuilderEmptyInputThrowingException() { | ||
18 | List<Sq<Block>> blocks = new ArrayList<Sq<Block>>(); | ||
19 | new Board(blocks); | ||
20 | |||
21 | } | ||
22 | |||
23 | |||
24 | @Test(expected=IllegalArgumentException.class) | ||
25 | public void isBoardBuilderIllegalInputThrowingException() { | ||
26 | List<Sq<Block>> blocks = new ArrayList<Sq<Block>>(); | ||
27 | |||
28 | for (int i = 0;i<8;i++) { | ||
29 | blocks.add(Sq.constant(Block.FREE)); | ||
30 | } | ||
31 | |||
32 | new Board(blocks); | ||
33 | |||
34 | } | ||
35 | |||
36 | @Test(expected=IllegalArgumentException.class) | ||
37 | public void isOfRowsEmptyInputMatrixThrowingException() { | ||
38 | List<List<Block>> rowsList = new ArrayList<List<Block>>(); | ||
39 | Board.ofRows(rowsList); | ||
40 | } | ||
41 | |||
42 | @Test(expected=IllegalArgumentException.class) | ||
43 | public void isOfRowsIllegalInputThrowingException() { | ||
44 | List<List<Block>> rowsList = new ArrayList<List<Block>>(); | ||
45 | List<Block> sampleRow = new ArrayList<Block>(); | ||
46 | |||
47 | for (int i = 0;i < 8 ;i++) { | ||
48 | sampleRow.add(Block.FREE); | ||
49 | } | ||
50 | rowsList.add(sampleRow); | ||
51 | |||
52 | assertTrue(Board.ofRows(rowsList) instanceof Board); | ||
53 | } | ||
54 | |||
55 | @Test | ||
56 | public void buildBoardFromRowsMatrix() { | ||
57 | List<List<Block>> rowsList = new ArrayList<List<Block>>() ; | ||
58 | |||
59 | for (int i = 0; i < 13; i++) { | ||
60 | List<Block> sampleRow = new ArrayList<Block>(); | ||
61 | for (int j = 0; j < 15; j++) { | ||
62 | sampleRow.add(Block.FREE); | ||
63 | } | ||
64 | rowsList.add(sampleRow); | ||
65 | } | ||
66 | |||
67 | assertTrue(Board.ofRows(rowsList) instanceof Board); | ||
68 | } | ||
69 | |||
70 | @Test(expected=IllegalArgumentException.class) | ||
71 | public void isOfInnerBlocksWalledEmptyInputMatrixThrowingException() { | ||
72 | List<List<Block>> rowsList = new ArrayList<List<Block>>(); | ||
73 | Board.ofInnerBlocksWalled(rowsList); | ||
74 | } | ||
75 | |||
76 | @Test(expected=IllegalArgumentException.class) | ||
77 | public void isOfInnerBlocksWalledIllegalInputThrowingException() { | ||
78 | List<List<Block>> rowsList = new ArrayList<List<Block>>(); | ||
79 | List<Block> sampleRow = new ArrayList<Block>(); | ||
80 | |||
81 | for (int i = 0;i < 8 ;i++) { | ||
82 | sampleRow.add(Block.FREE); | ||
83 | } | ||
84 | rowsList.add(sampleRow); | ||
85 | |||
86 | assertTrue(Board.ofInnerBlocksWalled(rowsList) instanceof Board); | ||
87 | } | ||
88 | |||
89 | @Test | ||
90 | public void buildBoardFromInnerBlocks() { | ||
91 | List<List<Block>> rowsList = new ArrayList<List<Block>>() ; | ||
92 | |||
93 | for (int i = 0; i < 11; i++) { | ||
94 | List<Block> sampleRow = new ArrayList<Block>(); | ||
95 | for (int j = 0; j < 13; j++) { | ||