This repository has been archived on 2021-02-18. You can view files and clone it, but cannot push or open issues or pull requests.
chess/src/dev/kske/chess/test/BoardCloneTest.java
CyB3RC0nN0R 9cfd06230c Fixed rendering
+ Cloning support in Board and Piece
- Using clones for board operations that interfere with rendering
- Fixed repaint calls
+ Unit test for testing board cloning
2019-07-08 06:41:10 +02:00

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]);
}
}