Fixed memory leak, improved copy constructors

This commit is contained in:
2019-09-19 21:31:24 +02:00
parent 1ecafa5485
commit 54e4a0e2e4
7 changed files with 71 additions and 52 deletions

View File

@ -6,10 +6,7 @@ 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.Move;
import dev.kske.chess.board.Piece.Color;
import dev.kske.chess.board.Queen;
/**
* Project: <strong>Chess</strong><br>
@ -34,7 +31,7 @@ class BoardTest {
*/
@Test
void testClone() {
Board clone = (Board) board.clone();
Board clone = new Board(board);
assertNotSame(clone, board);
assertNotSame(clone.getBoardArr(), board.getBoardArr());

View File

@ -39,10 +39,16 @@ class LogTest {
*/
@Test
void testClone() {
Log other = new Log(log);
Log other = new Log(log, false);
log.setActiveColor(Color.WHITE);
other.setActiveColor(Color.BLACK);
assertNotEquals(other.getActiveColor(), log.getActiveColor());
assertNotEquals(log.getActiveColor(), other.getActiveColor());
log.add(Move.fromSAN("a2a4"), null, true);
log.add(Move.fromSAN("a4a5"), null, true);
other.add(Move.fromSAN("a2a4"), null, true);
other.add(Move.fromSAN("a4a5"), null, true);
assertNotEquals(log.getRoot(), other.getRoot());
assertNotEquals(log.getRoot().getVariations(), other.getRoot().getVariations());
}
/**