CyB3RC0nN0R
9cfd06230c
+ Cloning support in Board and Piece - Using clones for board operations that interfere with rendering - Fixed repaint calls + Unit test for testing board cloning
45 lines
1.0 KiB
Java
45 lines
1.0 KiB
Java
package dev.kske.chess.test;
|
|
|
|
import static org.junit.Assert.assertNotEquals;
|
|
import static org.junit.Assert.assertNotSame;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import dev.kske.chess.board.Board;
|
|
import dev.kske.chess.board.Piece.Color;
|
|
import dev.kske.chess.board.Queen;
|
|
|
|
/**
|
|
* Project: <strong>Chess</strong><br>
|
|
* File: <strong>BoardCloneTest.java</strong><br>
|
|
* Created: <strong>08.07.2019</strong><br>
|
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
|
*/
|
|
class BoardCloneTest {
|
|
|
|
Board board;
|
|
|
|
/**
|
|
* @throws java.lang.Exception
|
|
*/
|
|
@BeforeEach
|
|
void setUp() throws Exception {
|
|
board = new Board();
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link dev.kske.chess.board.Board#clone()}.
|
|
*/
|
|
@Test
|
|
void testClone() {
|
|
Board clone = (Board) board.clone();
|
|
assertNotSame(clone, board);
|
|
assertNotSame(clone.getBoardArr(), board.getBoardArr());
|
|
|
|
clone.getBoardArr()[0][0] = new Queen(Color.BLACK, clone);
|
|
assertNotEquals(clone.getBoardArr()[0][0], board.getBoardArr()[0][0]);
|
|
}
|
|
|
|
}
|