aboutsummaryrefslogtreecommitdiff
path: root/test/ch/epfl
diff options
context:
space:
mode:
authorPacien2016-03-15 14:54:24 +0100
committerPacien2016-03-15 14:54:24 +0100
commitcd660d9d08a3c396afc3a9b7ba0e4b30cab26a54 (patch)
treeb099dbb7ab11c2c18070b2c7a41872a60c678c14 /test/ch/epfl
parent5309cf4c441571a94e6c0033765ec43a3dc67ec8 (diff)
parent9ab2568b7519615165fa869c1852b0afbb4950e7 (diff)
downloadxblast-cd660d9d08a3c396afc3a9b7ba0e4b30cab26a54.tar.gz
Merge branch '04_bonus_and_game_state' into 'master'
04 bonus and game state See merge request !4
Diffstat (limited to 'test/ch/epfl')
-rw-r--r--test/ch/epfl/xblast/ListsTest.java15
-rw-r--r--test/ch/epfl/xblast/namecheck/NameCheck04.java78
2 files changed, 93 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java
index b898399..b18b05e 100644
--- a/test/ch/epfl/xblast/ListsTest.java
+++ b/test/ch/epfl/xblast/ListsTest.java
@@ -4,6 +4,7 @@ import org.junit.Test;
4 4
5import java.util.ArrayList; 5import java.util.ArrayList;
6import java.util.Arrays; 6import java.util.Arrays;
7import java.util.LinkedList;
7import java.util.List; 8import java.util.List;
8import java.util.stream.Collectors; 9import java.util.stream.Collectors;
9import java.util.stream.IntStream; 10import java.util.stream.IntStream;
@@ -48,4 +49,18 @@ public class ListsTest {
48 assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i)); 49 assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i));
49 } 50 }
50 51
52 @Test
53 public void isListPermuted() {
54 List<Integer> sampleList = Arrays.asList(1, 2, 3);
55 List<List<Integer>> expected = new LinkedList<>();
56 expected.add(Arrays.asList(1, 2, 3));
57 expected.add(Arrays.asList(2, 1, 3));
58 expected.add(Arrays.asList(2, 3, 1));
59 expected.add(Arrays.asList(1, 3, 2));
60 expected.add(Arrays.asList(3, 1, 2));
61 expected.add(Arrays.asList(3, 2, 1));
62
63 assertEquals(expected, Lists.permutations(sampleList));
64 }
65
51} 66}
diff --git a/test/ch/epfl/xblast/namecheck/NameCheck04.java b/test/ch/epfl/xblast/namecheck/NameCheck04.java
new file mode 100644
index 0000000..dc6cfb2
--- /dev/null
+++ b/test/ch/epfl/xblast/namecheck/NameCheck04.java
@@ -0,0 +1,78 @@
1package ch.epfl.xblast.namecheck;
2
3import ch.epfl.cs108.Sq;
4import ch.epfl.xblast.Cell;
5import ch.epfl.xblast.Lists;
6import ch.epfl.xblast.PlayerID;
7import ch.epfl.xblast.Time;
8import ch.epfl.xblast.server.*;
9
10import java.util.List;
11import java.util.Optional;
12
13/**
14 * Classe abstraite utilisant tous les éléments de l'étape 4, pour essayer de
15 * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est
16 * pas un test unitaire, et n'a pas pour but d'être exécuté!
17 *
18 * @author EPFL
19 */
20abstract class NameCheck04 {
21
22 void checkLists() {
23 List<Integer> l1 = null;
24 List<List<Integer>> p1 = Lists.permutations(l1);
25 List<List<List<Integer>>> p2 = Lists.permutations(p1);
26 System.out.println(p2);
27 }
28
29 void checkBonus(boolean x) {
30 Bonus b = x ? Bonus.INC_BOMB : Bonus.INC_RANGE;
31 Player p = null;
32 p = b.applyTo(p);
33 }
34
35 void checkBlock(Block b) {
36 b = b.isBonus() ? Block.BONUS_BOMB : Block.BONUS_RANGE;
37 Bonus s = b.associatedBonus();
38 System.out.println(s);
39 }
40
41 void checkTime() {
42 Optional<Integer> o;
43 o = Optional.of(Time.S_PER_MIN);
44 o = Optional.of(Time.MS_PER_S);
45 o = Optional.of(Time.US_PER_S);
46 o = Optional.of(Time.NS_PER_S);
47 System.out.println(o);
48 }
49
50 void checkTicks() {
51 Optional<Integer> o;
52 o = Optional.of(Ticks.TICKS_PER_SECOND);
53 o = Optional.of(Ticks.TICK_NANOSECOND_DURATION);
54 o = Optional.of(Ticks.TOTAL_TICKS);
55 System.out.println(o);
56 }
57
58 void checkGameState() {
59 int ts = 0;
60 Board b = null;
61 List<Player> ps = null;
62 List<Bomb> bs = null;
63 List<Sq<Sq<Cell>>> es = null;
64 List<Sq<Cell>> xs = null;
65 GameState s = new GameState(ts, b, ps, bs, es, xs);
66 s = new GameState(b, ps);
67 ts = s.ticks();
68 if (s.isGameOver()) {
69 Optional<Double> t = Optional.of(s.remainingTime());
70 System.out.println(t.get());
71 }
72 Optional<PlayerID> w = s.winner();
73 b = s.board();
74 ps = s.isGameOver() ? s.alivePlayers() : s.players();
75 System.out.println(w);
76 }
77
78}