1.1 --- a/quoridor/src/main/java/cz/xelfi/quoridor/Move.java Sat Jun 06 14:48:02 2009 +0200
1.2 +++ b/quoridor/src/main/java/cz/xelfi/quoridor/Move.java Sat Jun 06 14:51:46 2009 +0200
1.3 @@ -95,6 +95,9 @@
1.4 if (column < 'A' || 'H' < column) {
1.5 throw new IllegalPositionException ("x coordinate has to be from A to H"); // NOI18N
1.6 }
1.7 + if (row < 1 || row > 8) {
1.8 + throw new IllegalPositionException ("y coordinate has to be from 1 to 8"); // NOI18N
1.9 + }
1.10 return new Move(new Fence ((column - 'A') * 2 + 1, row * 2 - 1, orientation));
1.11 }
1.12
2.1 --- a/quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java Sat Jun 06 14:48:02 2009 +0200
2.2 +++ b/quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java Sat Jun 06 14:51:46 2009 +0200
2.3 @@ -28,6 +28,8 @@
2.4 import cz.xelfi.quoridor.Fence.Orientation;
2.5 import cz.xelfi.quoridor.Player.Direction;
2.6 import java.util.List;
2.7 +import java.util.logging.Level;
2.8 +import java.util.logging.Logger;
2.9 import junit.framework.TestCase;
2.10
2.11 /**
2.12 @@ -367,6 +369,15 @@
2.13
2.14 }
2.15
2.16 + public void testDetectInvalidFence() {
2.17 + try {
2.18 + Move m = Move.fence('D', 9, Orientation.HORIZONTAL);
2.19 + fail("Move shall not be allowed: " + m);
2.20 + } catch (IllegalPositionException ex) {
2.21 + // OK
2.22 + }
2.23 + }
2.24 +
2.25 public void testEqualityOfMoves() throws Exception {
2.26
2.27 for (Direction m1 : Direction.values()) {