Fixed memory leak, improved copy constructors
This commit is contained in:
@ -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());
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user