Commit ec7d9442 by Paktalin

Rewrote PositionTest

parent 450db60e
Showing with 13 additions and 49 deletions
package com.paktalin.chess; package com.paktalin.chess;
import com.paktalin.chess.pieces.Bishop;
import com.paktalin.chess.pieces.Pawn;
import com.paktalin.chess.pieces.Piece;
import javafx.geometry.Pos;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
...@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals; ...@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/ */
class PositionTest { class PositionTest {
private Board board; private Position position;
@BeforeEach
void init() {
board = Board.createEmpty();
}
@Test
void testCreate() {
Position position = Position.create("a8");
assertEquals("a8", position.toString());
assertEquals(0, position.getIntColumn());
assertEquals(7, position.getRow());
}
@Test
void testStrengthByPosition() {
verifyStrength(new Bishop(Color.Black), "b5", 3.0);
verifyStrength(new Pawn(Color.White), "a2", 1.0);
verifyStrength(new Pawn(Color.White), "a3", 0.5);
assertEquals(0.5, board.getPieceAtPosition("a2").getStrength());
}
private void verifyStrength(Piece piece, String position, double strength) {
board.placePiece(piece, position);
piece = board.getPieceAtPosition(position);
assertEquals(strength, piece.getStrength());
}
@Test @Test
void create() { void createFromString() {
Position position = Position.create("b4"); position = Position.create("b4");
assertEquals('b', position.getColumn()); assertEquals('b', position.getColumn());
assertEquals(1, position.getIntColumn()); assertEquals(1, position.getIntColumn());
assertEquals('4', position.getCharRow()); assertEquals('4', position.getCharRow());
assertEquals(3, position.getRow()); assertEquals(3, position.getRow());
} }
// TODO: 2/26/2019 finish the test methods
@Test @Test
void create1() { void createFromInts() {
position = Position.create(1, 2);
assertEquals(1, position.getRow());
assertEquals('2', position.getCharRow());
assertEquals('c', position.getColumn());
assertEquals(2, position.getIntColumn());
} }
@Test @Test
void toStringTest() { void toStringTest() {
} position = Position.create("b4");
assertEquals("b4", position.toString());
@Test position = Position.create(2, 4);
void getRow() { assertEquals("e3", position.toString());
}
@Test
void getColumn() {
}
@Test
void getIntColumn() {
} }
} }
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 sign in to comment