summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/tests
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-21 10:44:42 +0100
committerPacien TRAN-GIRARD2015-11-21 10:44:42 +0100
commit90bd766f361083f6fd9e39ff080c83fcc606832f (patch)
treedf81a931c9565a4b227068680087f58fdace1859 /src/ch/epfl/maze/tests
parent655ac88f4e73b2df532a451aedf5a561ea1b0d2c (diff)
downloadmaze-solver-90bd766f361083f6fd9e39ff080c83fcc606832f.tar.gz
Reformat imported code
Diffstat (limited to 'src/ch/epfl/maze/tests')
-rw-r--r--src/ch/epfl/maze/tests/AnimalTest.java169
-rw-r--r--src/ch/epfl/maze/tests/Competition.java263
-rw-r--r--src/ch/epfl/maze/tests/DaedalusTest.java209
-rw-r--r--src/ch/epfl/maze/tests/GhostsTest.java246
-rw-r--r--src/ch/epfl/maze/tests/MazeTest.java117
-rw-r--r--src/ch/epfl/maze/tests/WorldTest.java625
-rw-r--r--src/ch/epfl/maze/tests/ZooTest.java364
7 files changed, 978 insertions, 1015 deletions
diff --git a/src/ch/epfl/maze/tests/AnimalTest.java b/src/ch/epfl/maze/tests/AnimalTest.java
index c4c9220..4a590ae 100644
--- a/src/ch/epfl/maze/tests/AnimalTest.java
+++ b/src/ch/epfl/maze/tests/AnimalTest.java
@@ -1,100 +1,95 @@
1package ch.epfl.maze.tests; 1package ch.epfl.maze.tests;
2 2
3import junit.framework.TestCase;
4
5import org.junit.Test;
6
7import ch.epfl.maze.physical.Animal; 3import ch.epfl.maze.physical.Animal;
8import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
9import ch.epfl.maze.util.Vector2D; 5import ch.epfl.maze.util.Vector2D;
6import junit.framework.TestCase;
7import org.junit.Test;
10 8
11/** 9/**
12 * Test case for {@code Animal} implementation. 10 * Test case for {@code Animal} implementation.
13 *
14 */ 11 */
15 12
16public class AnimalTest extends TestCase { 13public class AnimalTest extends TestCase {
17 14
18 /** 15 /**
19 * Test case for {@code getPosition()}. 16 * Test case for {@code getPosition()}.
20 */ 17 */
21 18
22 @Test 19 @Test
23 public void testGetPosition() { 20 public void testGetPosition() {
24 Animal animal = new MockAnimal(new Vector2D(2, 1)); 21 Animal animal = new MockAnimal(new Vector2D(2, 1));
25 22
26 // checks getPosition() 23 // checks getPosition()
27 assertEquals(new Vector2D(2, 1), animal.getPosition()); 24 assertEquals(new Vector2D(2, 1), animal.getPosition());
28 } 25 }
29 26
30 /** 27 /**
31 * Test case for {@code setPosition(Vector2D position)}. 28 * Test case for {@code setPosition(Vector2D position)}.
32 */ 29 */
33 30
34 @Test 31 @Test
35 public void testSetPosition() { 32 public void testSetPosition() {
36 Animal animal = new MockAnimal(new Vector2D(2, 1)); 33 Animal animal = new MockAnimal(new Vector2D(2, 1));
37 34
38 // checks setPosition(Vector2D position) 35 // checks setPosition(Vector2D position)
39 animal.setPosition(new Vector2D(3, 5)); 36 animal.setPosition(new Vector2D(3, 5));
40 assertEquals(new Vector2D(3, 5), animal.getPosition()); 37 assertEquals(new Vector2D(3, 5), animal.getPosition());
41 } 38 }
42 39
43 /** 40 /**
44 * Test case for {@code update(Direction dir)}. 41 * Test case for {@code update(Direction dir)}.
45 */ 42 */
46 43
47 @Test 44 @Test
48 public void testUpdate() { 45 public void testUpdate() {
49 Animal animal = new MockAnimal(new Vector2D(2, 1)); 46 Animal animal = new MockAnimal(new Vector2D(2, 1));
50 47
51 // checks update(Direction dir) with NONE 48 // checks update(Direction dir) with NONE
52 animal.update(Direction.NONE); 49 animal.update(Direction.NONE);
53 assertEquals(new Vector2D(2, 1), animal.getPosition()); 50 assertEquals(new Vector2D(2, 1), animal.getPosition());
54 51
55 // checks update(Direction dir) with DOWN 52 // checks update(Direction dir) with DOWN
56 animal.update(Direction.DOWN); 53 animal.update(Direction.DOWN);
57 assertEquals(new Vector2D(2, 2), animal.getPosition()); 54 assertEquals(new Vector2D(2, 2), animal.getPosition());
58 55
59 // checks update(Direction dir) with UP 56 // checks update(Direction dir) with UP
60 animal.update(Direction.UP); 57 animal.update(Direction.UP);
61 assertEquals(new Vector2D(2, 1), animal.getPosition()); 58 assertEquals(new Vector2D(2, 1), animal.getPosition());
62 59
63 // checks update(Direction dir) with RIGHT 60 // checks update(Direction dir) with RIGHT
64 animal.update(Direction.RIGHT); 61 animal.update(Direction.RIGHT);
65 assertEquals(new Vector2D(3, 1), animal.getPosition()); 62 assertEquals(new Vector2D(3, 1), animal.getPosition());
66 63
67 // checks update(Direction dir) with LEFT 64 // checks update(Direction dir) with LEFT
68 animal.update(Direction.LEFT); 65 animal.update(Direction.LEFT);
69 assertEquals(new Vector2D(2, 1), animal.getPosition()); 66 assertEquals(new Vector2D(2, 1), animal.getPosition());
70 } 67 }
71 68
72 /** 69 /**
73 * Mock class that makes {@code Animal} concrete. 70 * Mock class that makes {@code Animal} concrete.
74 * 71 */
75 */ 72
76 73 private class MockAnimal extends Animal {
77 private class MockAnimal extends Animal { 74
78 75 /**
79 /** 76 * Creates a concrete instance of the {@code Animal} class.
80 * Creates a concrete instance of the {@code Animal} class. 77 *
81 * 78 * @param labyrinth Actual maze
82 * @param labyrinth 79 */
83 * Actual maze 80
84 */ 81 public MockAnimal(Vector2D position) {
85 82 super(position);
86 public MockAnimal(Vector2D position) { 83 }
87 super(position); 84
88 } 85 @Override
89 86 public Direction move(Direction[] choices) {
90 @Override 87 return null;
91 public Direction move(Direction[] choices) { 88 }
92 return null; 89
93 } 90 @Override
94 91 public Animal copy() {
95 @Override 92 return null;
96 public Animal copy() { 93 }
97 return null; 94 }
98 }
99 }
100} 95}
diff --git a/src/ch/epfl/maze/tests/Competition.java b/src/ch/epfl/maze/tests/Competition.java
index 4ed42b6..ccbbe73 100644
--- a/src/ch/epfl/maze/tests/Competition.java
+++ b/src/ch/epfl/maze/tests/Competition.java
@@ -1,25 +1,19 @@
1package ch.epfl.maze.tests; 1package ch.epfl.maze.tests;
2 2
3import static org.junit.Assert.assertTrue;
4
5import java.util.HashMap;
6import java.util.List;
7import java.util.Map;
8
9import org.junit.BeforeClass;
10import org.junit.Test;
11
12import ch.epfl.maze.physical.Animal; 3import ch.epfl.maze.physical.Animal;
13import ch.epfl.maze.physical.Maze; 4import ch.epfl.maze.physical.Maze;
14import ch.epfl.maze.physical.zoo.Bear; 5import ch.epfl.maze.physical.zoo.*;
15import ch.epfl.maze.physical.zoo.Hamster;
16import ch.epfl.maze.physical.zoo.Monkey;
17import ch.epfl.maze.physical.zoo.Mouse;
18import ch.epfl.maze.physical.zoo.Panda;
19import ch.epfl.maze.physical.zoo.SpaceInvader;
20import ch.epfl.maze.simulation.MazeSimulation; 6import ch.epfl.maze.simulation.MazeSimulation;
21import ch.epfl.maze.simulation.Simulation; 7import ch.epfl.maze.simulation.Simulation;
22import ch.epfl.maze.util.LabyrinthGenerator; 8import ch.epfl.maze.util.LabyrinthGenerator;
9import org.junit.BeforeClass;
10import org.junit.Test;
11
12import java.util.HashMap;
13import java.util.List;
14import java.util.Map;
15
16import static org.junit.Assert.assertTrue;
23 17
24/** 18/**
25 * Competition of the {@code SpaceInvader} against the other animals. 19 * Competition of the {@code SpaceInvader} against the other animals.
@@ -36,128 +30,127 @@ import ch.epfl.maze.util.LabyrinthGenerator;
36 * winner against one animal if it obtained a positive score in the rivalry 30 * winner against one animal if it obtained a positive score in the rivalry
37 * against it.</li> 31 * against it.</li>
38 * </ul> 32 * </ul>
39 *
40 */ 33 */
41 34
42public class Competition { 35public class Competition {
43 36
44 static final String COMPETITION_MAZE_FILE = "labyrinth.txt"; 37 static final String COMPETITION_MAZE_FILE = "labyrinth.txt";
45 static final int NUMBER_OF_ROUNDS = 1000; 38 static final int NUMBER_OF_ROUNDS = 1000;
46 static HashMap<String, Integer> rivalries; 39 static HashMap<String, Integer> rivalries;
47 40
48 /** 41 /**
<