Commit 97966790 authored by Shaun Burch's avatar Shaun Burch

#5 Remove Android log dep., simple Board unit tests

parent 5252a7e7
Pipeline #23091840 passed with stages
in 7 minutes and 26 seconds
package com.example.tictactoe;
import android.util.Log;
import java.util.Arrays;
/**
......@@ -39,10 +37,10 @@ public class Board {
try {
mCells[cellY][cellX] = mark;
} catch (IndexOutOfBoundsException e) {
Log.e(TAG, String.format("Cell {x: %1d, y: %2d} is out of bounds!", cellX, cellY));
System.out.println(String.format("%1s: Cell {x: %2d, y: %3d} is out of bounds!", TAG, cellX, cellY));
}
Log.d(TAG, Arrays.deepToString(mCells));
System.out.println(String.format("%1s: markCell: %2s", TAG, Arrays.deepToString(mCells)));
return true;
}
......
package com.example.tictactoe;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class BoardTest {
@Test
public void markCell() {
Mark[][] expected = {
{Mark.X, Mark.EMPTY, Mark.EMPTY},
{Mark.EMPTY, Mark.EMPTY, Mark.O},
{Mark.EMPTY, Mark.EMPTY, Mark.EMPTY},
};
// Mark cells on board
Board board = new Board();
board.markCell(Mark.X, 0, 0);
board.markCell(Mark.O, 2, 1);
assertArrayEquals(expected, board.getCells());
}
@Test
public void getCells() {
Mark[][] expected = {
{Mark.EMPTY, Mark.EMPTY, Mark.EMPTY},
{Mark.EMPTY, Mark.EMPTY, Mark.EMPTY},
{Mark.EMPTY, Mark.EMPTY, Mark.EMPTY},
};
Mark[][] actual = new Board().getCells();
assertArrayEquals(expected, actual);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment