jtulach@34
|
1 |
/*
|
jtulach@34
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
jtulach@34
|
3 |
*
|
jtulach@34
|
4 |
* The contents of this file are subject to the terms of either the GNU
|
jtulach@34
|
5 |
* General Public License Version 2 only ("GPL") or the Common
|
jtulach@34
|
6 |
* Development and Distribution License("CDDL") (collectively, the
|
jtulach@34
|
7 |
* "License"). You may not use this file except in compliance with the
|
jtulach@34
|
8 |
* License. You can obtain a copy of the License at
|
jtulach@34
|
9 |
* http://www.netbeans.org/cddl-gplv2.html
|
jtulach@34
|
10 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
jtulach@34
|
11 |
* specific language governing permissions and limitations under the
|
jtulach@34
|
12 |
* License. When distributing the software, include this License Header
|
jtulach@34
|
13 |
* Notice in each file and include the License file at
|
jtulach@34
|
14 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
|
jtulach@34
|
15 |
* particular file as subject to the "Classpath" exception as provided
|
jtulach@34
|
16 |
* by Sun in the GPL Version 2 section of the License file that
|
jtulach@34
|
17 |
* accompanied this code. If applicable, add the following below the
|
jtulach@34
|
18 |
* License Header, with the fields enclosed by brackets [] replaced by
|
jtulach@34
|
19 |
* your own identifying information:
|
jtulach@34
|
20 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
jtulach@34
|
21 |
*
|
jtulach@34
|
22 |
* Contributor(s):
|
jtulach@34
|
23 |
*
|
jtulach@34
|
24 |
* Portions Copyrighted 2009 Jaroslav Tulach
|
jtulach@34
|
25 |
*/
|
jtulach@34
|
26 |
|
jtulach@34
|
27 |
package cz.xelfi.quoridor;
|
jtulach@34
|
28 |
|
jtulach@34
|
29 |
import cz.xelfi.quoridor.Fence.Orientation;
|
jtulach@34
|
30 |
import cz.xelfi.quoridor.Player.Direction;
|
jtulach@34
|
31 |
import org.junit.Test;
|
jtulach@34
|
32 |
import static org.junit.Assert.*;
|
jtulach@34
|
33 |
|
jtulach@34
|
34 |
/**
|
jtulach@34
|
35 |
*
|
jtulach@34
|
36 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jtulach@34
|
37 |
*/
|
jtulach@34
|
38 |
public class MoveTest {
|
jtulach@34
|
39 |
|
jtulach@34
|
40 |
public MoveTest() {
|
jtulach@34
|
41 |
}
|
jtulach@34
|
42 |
|
jtulach@34
|
43 |
@Test
|
jtulach@34
|
44 |
public void testNorth() throws Exception {
|
jtulach@34
|
45 |
checkValueOf("N", Move.NORTH);
|
jtulach@34
|
46 |
}
|
jtulach@34
|
47 |
@Test
|
jtulach@34
|
48 |
public void testSouth() throws Exception {
|
jtulach@34
|
49 |
checkValueOf("S", Move.SOUTH);
|
jtulach@34
|
50 |
}
|
jtulach@34
|
51 |
@Test
|
jtulach@34
|
52 |
public void testEast() throws Exception {
|
jtulach@34
|
53 |
checkValueOf("E", Move.EAST);
|
jtulach@34
|
54 |
}
|
jtulach@34
|
55 |
@Test
|
jtulach@34
|
56 |
public void testWest() throws Exception {
|
jtulach@34
|
57 |
checkValueOf("W", Move.WEST);
|
jtulach@34
|
58 |
}
|
jtulach@34
|
59 |
@Test
|
jtulach@75
|
60 |
public void testRegisn() throws Exception {
|
jtulach@75
|
61 |
checkValueOf("RESIGN", Move.RESIGN);
|
jtulach@75
|
62 |
}
|
jtulach@75
|
63 |
@Test
|
jtulach@34
|
64 |
public void testJumps() throws Exception {
|
jtulach@34
|
65 |
for (Direction d1 : Direction.values()) {
|
jtulach@34
|
66 |
for (Direction d2 : Direction.values()) {
|
jtulach@34
|
67 |
checkValueOf("" + d1.name().charAt(0) + d2.name().charAt(0), Move.jump(d1, d2));
|
jtulach@34
|
68 |
}
|
jtulach@34
|
69 |
}
|
jtulach@34
|
70 |
}
|
jtulach@34
|
71 |
@Test
|
jtulach@34
|
72 |
public void testFences() throws Exception {
|
jtulach@34
|
73 |
for (int i = 1; i <= 8; i++) {
|
jtulach@34
|
74 |
for (int j = 0; i < 8; i++) {
|
jtulach@34
|
75 |
String h = "H" + (char)('A'+ j) + i;
|
jtulach@34
|
76 |
String v = "V" + (char)('A'+ j) + i;
|
jtulach@34
|
77 |
|
jtulach@34
|
78 |
Move hm = Move.fence((char) ('A' + j), i, Orientation.HORIZONTAL);
|
jtulach@34
|
79 |
Move vm = Move.fence((char) ('A' + j), i, Orientation.VERTICAL);
|
jtulach@34
|
80 |
|
jtulach@34
|
81 |
checkValueOf(h, hm);
|
jtulach@34
|
82 |
checkValueOf(v, vm);
|
jtulach@34
|
83 |
}
|
jtulach@34
|
84 |
}
|
jtulach@34
|
85 |
}
|
jtulach@34
|
86 |
|
jtulach@34
|
87 |
private static void checkValueOf(String txt, Move move) throws Exception {
|
jtulach@34
|
88 |
assertEquals("toString", txt, move.toString());
|
jtulach@34
|
89 |
assertEquals("valueOf", move, Move.valueOf(txt));
|
jtulach@34
|
90 |
}
|
jtulach@34
|
91 |
|
jtulach@34
|
92 |
} |