Commit ec7d9442 by Paktalin

Rewrote PositionTest

parent 450db60e
Showing with 13 additions and 49 deletions
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 static org.junit.jupiter.api.Assertions.assertEquals;
......@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
class PositionTest {
private Board board;
@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());
}
private Position position;
@Test
void create() {
Position position = Position.create("b4");
void createFromString() {
position = Position.create("b4");
assertEquals('b', position.getColumn());
assertEquals(1, position.getIntColumn());
assertEquals('4', position.getCharRow());
assertEquals(3, position.getRow());
}
// TODO: 2/26/2019 finish the test methods
@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
void toStringTest() {
}
@Test
void getRow() {
}
@Test
void getColumn() {
}
@Test
void getIntColumn() {
position = Position.create("b4");
assertEquals("b4", position.toString());
position = Position.create(2, 4);
assertEquals("e3", position.toString());
}
}
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