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.

50 lines
1.3 KiB

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