Skip to content

Commit

Permalink
BoardTest automated testing for canMove added
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Mar 30, 2016
1 parent e1ed8da commit 2059be3
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/test/BoardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,40 @@
import model.Board;

public class BoardTest {

public static void assertCanMove(Board b, int i, int j, int dest_i, int dest_j) {
assert(b.canMove(i, j, dest_i,dest_j)) :
"Can move from (" + i + "," + j +") to (" + dest_i + "," + dest_j + ").";
}

public static void assertCannotMove(Board b, int i, int j, int dest_i, int dest_j) {
assert(!b.canMove(i, j, dest_i,dest_j)) :
"Cannot move from (" + i + "," + j +") to (" + dest_i + "," + dest_j + ").";
}


public static void movementTest() {
Board b = new Board();
assertCannotMove(b, 0, 6, 1, 5); // move black onto another
assertCannotMove(b, 6, 2, 7, 1); // move red up
assertCannotMove(b, 0, 2, -1, 3); // move red out of bounds
assertCannotMove(b, 7, 5, 8, 4); // move black out of bounds
assertCanMove(b, 3, 5, 4, 4); // move black up right
assertCanMove(b, 3, 5, 2, 3); // move black up left
assertCanMove(b, 1, 5, 2, 4); // move blkac up right
assertCanMove(b, 0, 2, 1, 3); // move red down right
assertCanMove(b, 4, 2, 3, 3); // move red down left
assertCanMove(b, 4, 2, 5, 3); // move red down right
}

public static void printTest() {
Board b = new Board();
b.print();
}

public static void main(String[]args) {
Board checkers = new Board();
checkers.print();
printTest();
movementTest();
}
}

0 comments on commit 2059be3

Please sign in to comment.