aboutsummaryrefslogtreecommitdiff
path: root/test/ch
diff options
context:
space:
mode:
Diffstat (limited to 'test/ch')
-rw-r--r--test/ch/epfl/xblast/server/GameStateSerializerTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/server/GameStateSerializerTest.java b/test/ch/epfl/xblast/server/GameStateSerializerTest.java
new file mode 100644
index 0000000..ff8c75a
--- /dev/null
+++ b/test/ch/epfl/xblast/server/GameStateSerializerTest.java
@@ -0,0 +1,49 @@
1package ch.epfl.xblast.server;
2
3import ch.epfl.xblast.server.painter.BoardPainter;
4import org.junit.Test;
5
6import java.util.Arrays;
7import java.util.List;
8
9import static org.junit.Assert.assertEquals;
10
11/**
12 * @author Pacien TRAN-GIRARD (261948)
13 * @author Timothée Floure (257420)
14 */
15public class GameStateSerializerTest {
16
17 private static final BoardPainter BOARD_PAINTER = BoardPainter.DEFAULT_BOARD_PAINTER;
18
19 private static final GameState SAMPLE_GAME_STATE = GameState.DEFAULT_GAME_STATE;
20 private static final Byte[] SERIALIZED_GAME_STATE = {
21 // Serialized Board
22 121, -50, 2, 1, -2, 0, 3, 1, 3, 1, -2, 0, 1, 1, 3, 1, 3,
23 1, 3, 1, 1, -2, 0, 1, 3, 1, 3, -2, 0, -1, 1, 3, 1, 3, 1,
24 3, 1, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
25 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2,
26 3, 1, 0, 0, 3, 1, 3, 1, 0, 0, 1, 1, 3, 1, 1, 0, 0, 1, 3,
27 1, 3, 0, 0, -1, 1, 3, 1, 1, -5, 2, 3, 2, 3, -5, 2, 3, 2,
28 3, 1, -2, 0, 3, -2, 0, 1, 3, 2, 1, 2,
29
30 // Explosions (blasts & bombs)
31 4, -128, 16, -63, 16,
32
33 // Players
34 3, 24, 24, 6,
35 3, -40, 24, 26,
36 3, -40, -72, 46,
37 3, 24, -72, 66,
38
39 // Ticks
40 60
41 };
42
43 @Test
44 public void isInitialGameStateSerialized() {
45 List<Byte> serialized = GameStateSerializer.serialize(BOARD_PAINTER, SAMPLE_GAME_STATE);
46 assertEquals(Arrays.asList(SERIALIZED_GAME_STATE), serialized);
47 }
48
49}