jtulach@34
|
1 |
/*
|
jaroslav@264
|
2 |
* Quoridor server and related libraries
|
jaroslav@264
|
3 |
* Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
|
jtulach@34
|
4 |
*
|
jaroslav@264
|
5 |
* This program is free software: you can redistribute it and/or modify
|
jaroslav@264
|
6 |
* it under the terms of the GNU General Public License as published by
|
jaroslav@264
|
7 |
* the Free Software Foundation, either version 3 of the License.
|
jtulach@34
|
8 |
*
|
jaroslav@264
|
9 |
* This program is distributed in the hope that it will be useful,
|
jaroslav@264
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jaroslav@264
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jaroslav@264
|
12 |
* GNU General Public License for more details.
|
jtulach@34
|
13 |
*
|
jaroslav@264
|
14 |
* You should have received a copy of the GNU General Public License
|
jaroslav@264
|
15 |
* along with this program. Look for COPYING file in the top folder.
|
jaroslav@264
|
16 |
* If not, see http://www.gnu.org/licenses/.
|
jtulach@34
|
17 |
*/
|
jtulach@34
|
18 |
package cz.xelfi.quoridor;
|
jtulach@34
|
19 |
|
jtulach@34
|
20 |
import cz.xelfi.quoridor.Fence.Orientation;
|
jtulach@34
|
21 |
import cz.xelfi.quoridor.Player.Direction;
|
jtulach@34
|
22 |
import org.junit.Test;
|
jtulach@34
|
23 |
import static org.junit.Assert.*;
|
jtulach@34
|
24 |
|
jtulach@34
|
25 |
/**
|
jtulach@34
|
26 |
*
|
jtulach@34
|
27 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jtulach@34
|
28 |
*/
|
jtulach@34
|
29 |
public class MoveTest {
|
jtulach@34
|
30 |
|
jtulach@34
|
31 |
public MoveTest() {
|
jtulach@34
|
32 |
}
|
jtulach@34
|
33 |
|
jtulach@34
|
34 |
@Test
|
jtulach@34
|
35 |
public void testNorth() throws Exception {
|
jtulach@34
|
36 |
checkValueOf("N", Move.NORTH);
|
jtulach@34
|
37 |
}
|
jtulach@34
|
38 |
@Test
|
jtulach@34
|
39 |
public void testSouth() throws Exception {
|
jtulach@34
|
40 |
checkValueOf("S", Move.SOUTH);
|
jtulach@34
|
41 |
}
|
jtulach@34
|
42 |
@Test
|
jtulach@34
|
43 |
public void testEast() throws Exception {
|
jtulach@34
|
44 |
checkValueOf("E", Move.EAST);
|
jtulach@34
|
45 |
}
|
jtulach@34
|
46 |
@Test
|
jtulach@34
|
47 |
public void testWest() throws Exception {
|
jtulach@34
|
48 |
checkValueOf("W", Move.WEST);
|
jtulach@34
|
49 |
}
|
jtulach@34
|
50 |
@Test
|
jtulach@75
|
51 |
public void testRegisn() throws Exception {
|
jtulach@75
|
52 |
checkValueOf("RESIGN", Move.RESIGN);
|
jtulach@75
|
53 |
}
|
jtulach@75
|
54 |
@Test
|
jtulach@34
|
55 |
public void testJumps() throws Exception {
|
jtulach@34
|
56 |
for (Direction d1 : Direction.values()) {
|
jtulach@34
|
57 |
for (Direction d2 : Direction.values()) {
|
jtulach@34
|
58 |
checkValueOf("" + d1.name().charAt(0) + d2.name().charAt(0), Move.jump(d1, d2));
|
jtulach@34
|
59 |
}
|
jtulach@34
|
60 |
}
|
jtulach@34
|
61 |
}
|
jtulach@34
|
62 |
@Test
|
jtulach@34
|
63 |
public void testFences() throws Exception {
|
jtulach@34
|
64 |
for (int i = 1; i <= 8; i++) {
|
jtulach@34
|
65 |
for (int j = 0; i < 8; i++) {
|
jtulach@34
|
66 |
String h = "H" + (char)('A'+ j) + i;
|
jtulach@34
|
67 |
String v = "V" + (char)('A'+ j) + i;
|
jtulach@34
|
68 |
|
jtulach@34
|
69 |
Move hm = Move.fence((char) ('A' + j), i, Orientation.HORIZONTAL);
|
jtulach@34
|
70 |
Move vm = Move.fence((char) ('A' + j), i, Orientation.VERTICAL);
|
jtulach@34
|
71 |
|
jtulach@34
|
72 |
checkValueOf(h, hm);
|
jtulach@34
|
73 |
checkValueOf(v, vm);
|
jtulach@34
|
74 |
}
|
jtulach@34
|
75 |
}
|
jtulach@34
|
76 |
}
|
jtulach@34
|
77 |
|
jtulach@34
|
78 |
private static void checkValueOf(String txt, Move move) throws Exception {
|
jtulach@34
|
79 |
assertEquals("toString", txt, move.toString());
|
jtulach@34
|
80 |
assertEquals("valueOf", move, Move.valueOf(txt));
|
jtulach@34
|
81 |
}
|
jtulach@34
|
82 |
|
jtulach@34
|
83 |
} |