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