1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/quoridor/src/test/java/cz/xelfi/quoridor/MoveTest.java Sun Jul 12 13:35:58 2009 +0200
1.3 @@ -0,0 +1,92 @@
1.4 +/*
1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.6 + *
1.7 + * The contents of this file are subject to the terms of either the GNU
1.8 + * General Public License Version 2 only ("GPL") or the Common
1.9 + * Development and Distribution License("CDDL") (collectively, the
1.10 + * "License"). You may not use this file except in compliance with the
1.11 + * License. You can obtain a copy of the License at
1.12 + * http://www.netbeans.org/cddl-gplv2.html
1.13 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.14 + * specific language governing permissions and limitations under the
1.15 + * License. When distributing the software, include this License Header
1.16 + * Notice in each file and include the License file at
1.17 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
1.18 + * particular file as subject to the "Classpath" exception as provided
1.19 + * by Sun in the GPL Version 2 section of the License file that
1.20 + * accompanied this code. If applicable, add the following below the
1.21 + * License Header, with the fields enclosed by brackets [] replaced by
1.22 + * your own identifying information:
1.23 + * "Portions Copyrighted [year] [name of copyright owner]"
1.24 + *
1.25 + * Contributor(s):
1.26 + *
1.27 + * Portions Copyrighted 2009 Jaroslav Tulach
1.28 + */
1.29 +
1.30 +package cz.xelfi.quoridor;
1.31 +
1.32 +import cz.xelfi.quoridor.Fence.Orientation;
1.33 +import cz.xelfi.quoridor.Player.Direction;
1.34 +import org.junit.After;
1.35 +import org.junit.AfterClass;
1.36 +import org.junit.Before;
1.37 +import org.junit.BeforeClass;
1.38 +import org.junit.Test;
1.39 +import static org.junit.Assert.*;
1.40 +
1.41 +/**
1.42 + *
1.43 + * @author Jaroslav Tulach <jtulach@netbeans.org>
1.44 + */
1.45 +public class MoveTest {
1.46 +
1.47 + public MoveTest() {
1.48 + }
1.49 +
1.50 + @Test
1.51 + public void testNorth() throws Exception {
1.52 + checkValueOf("N", Move.NORTH);
1.53 + }
1.54 + @Test
1.55 + public void testSouth() throws Exception {
1.56 + checkValueOf("S", Move.SOUTH);
1.57 + }
1.58 + @Test
1.59 + public void testEast() throws Exception {
1.60 + checkValueOf("E", Move.EAST);
1.61 + }
1.62 + @Test
1.63 + public void testWest() throws Exception {
1.64 + checkValueOf("W", Move.WEST);
1.65 + }
1.66 + @Test
1.67 + public void testJumps() throws Exception {
1.68 + for (Direction d1 : Direction.values()) {
1.69 + for (Direction d2 : Direction.values()) {
1.70 + checkValueOf("" + d1.name().charAt(0) + d2.name().charAt(0), Move.jump(d1, d2));
1.71 + }
1.72 + }
1.73 + }
1.74 + @Test
1.75 + public void testFences() throws Exception {
1.76 + for (int i = 1; i <= 8; i++) {
1.77 + for (int j = 0; i < 8; i++) {
1.78 + String h = "H" + (char)('A'+ j) + i;
1.79 + String v = "V" + (char)('A'+ j) + i;
1.80 +
1.81 + Move hm = Move.fence((char) ('A' + j), i, Orientation.HORIZONTAL);
1.82 + Move vm = Move.fence((char) ('A' + j), i, Orientation.VERTICAL);
1.83 +
1.84 + checkValueOf(h, hm);
1.85 + checkValueOf(v, vm);
1.86 + }
1.87 + }
1.88 + }
1.89 +
1.90 + private static void checkValueOf(String txt, Move move) throws Exception {
1.91 + assertEquals("toString", txt, move.toString());
1.92 + assertEquals("valueOf", move, Move.valueOf(txt));
1.93 + }
1.94 +
1.95 +}
1.96 \ No newline at end of file