Browse Source

test: initial king movement

(own class was necessary to run other tests successfully)
feat-figureMovement
JD 4 years ago
parent
commit
16f4d9bbe4
  1. 25
      fh.fd.ci.client/src/main/java/de/fd/fh/FigureKing.java
  2. 28
      fh.fd.ci.client/src/test/java/de/fd/fh/FigureKingTest.java

25
fh.fd.ci.client/src/main/java/de/fd/fh/FigureKing.java

@ -0,0 +1,25 @@
package de.fd.fh;
public class FigureKing extends Figure
{
@Override
public boolean moveAllowed(int src, int dst, Figure[] field)
{
// TODO: Positionierung in einer Ecke beachten
if (dst != src-1
|| dst != src +1
|| dst != src -8
|| dst != src -8 -1
|| dst != src -8 +1
|| dst != src +8
|| dst != src +8 -1
|| dst != src +8 +1)
{
return false;
}
return super.moveAllowed(src, dst, field);
}
}

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

@ -0,0 +1,28 @@
package de.fd.fh;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class FigureKingTest
{
// K = Position (19), x = gültig (10, 11, 12, 18, 20, 26, 27, 28), rest nicht
// x x x
// x K x
// x x x
@Test
void checkInvalidKingMoves()
{
Figure f = new FigureKing();
for (int i = 0; i < 64; i++)
{
if (i != 10 && i != 11 && i != 12
&& i != 18 && i != 20
&& i != 26 && i != 27 && i != 28)
{
assertFalse(f.moveAllowed(19, i, new Figure[64]));
}
}
}
}
Loading…
Cancel
Save