Browse Source

refactoring: removed magic numbers

feat-figureMovement
JD 4 years ago
parent
commit
a3ce3541d7
  1. 26
      fh.fd.ci.client/src/test/java/de/fd/fh/FigureKingTest.java

26
fh.fd.ci.client/src/test/java/de/fd/fh/FigureKingTest.java

@ -2,6 +2,9 @@ package de.fd.fh;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.*;
class FigureKingTest
@ -15,14 +18,29 @@ class FigureKingTest
{
Figure f = new FigureKing();
int pos = 19;
ArrayList<Integer> possibleMoves = new ArrayList<>();
possibleMoves.add(pos - Figure.fieldLength - 1);
possibleMoves.add(pos - Figure.fieldLength);
possibleMoves.add(pos - Figure.fieldLength + 1);
possibleMoves.add(pos -1);
possibleMoves.add(pos + 1);
possibleMoves.add(pos + Figure.fieldLength - 1);
possibleMoves.add(pos + Figure.fieldLength);
possibleMoves.add(pos + Figure.fieldLength + 1);
for (int i = 0; i < 64; i++)
{
if (i != 10 && i != 11 && i != 12
&& i != 18 && i != 20
&& i != 26 && i != 27 && i != 28)
if (possibleMoves.contains(i))
{
assertFalse(f.moveAllowed(19, i, new Figure[64]));
continue;
}
assertFalse(f.moveAllowed(pos, i, new Figure[64]));
}
}
}
Loading…
Cancel
Save