You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. package de.fd.fh;
  2. import org.junit.jupiter.api.Test;
  3. import java.lang.reflect.Array;
  4. import java.util.ArrayList;
  5. import static org.junit.jupiter.api.Assertions.*;
  6. class FigureKingTest
  7. {
  8. // K = Position (19), x = gültig (10, 11, 12, 18, 20, 26, 27, 28), rest nicht
  9. // x x x
  10. // x K x
  11. // x x x
  12. @Test
  13. void checkInvalidKingMoves()
  14. {
  15. Figure f = new FigureKing();
  16. int pos = 19;
  17. ArrayList<Integer> possibleMoves = new ArrayList<>();
  18. possibleMoves.add(pos - Figure.fieldLength - 1);
  19. possibleMoves.add(pos - Figure.fieldLength);
  20. possibleMoves.add(pos - Figure.fieldLength + 1);
  21. possibleMoves.add(pos -1);
  22. possibleMoves.add(pos + 1);
  23. possibleMoves.add(pos + Figure.fieldLength - 1);
  24. possibleMoves.add(pos + Figure.fieldLength);
  25. possibleMoves.add(pos + Figure.fieldLength + 1);
  26. for (int i = 0; i < 64; i++)
  27. {
  28. if (possibleMoves.contains(i))
  29. {
  30. continue;
  31. }
  32. assertFalse(f.moveAllowed(pos, i, new Figure[64]));
  33. }
  34. }
  35. }