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.

62 lines
1.9 KiB

  1. package de.fd.fh;
  2. import org.junit.jupiter.api.Test;
  3. import static org.junit.jupiter.api.Assertions.*;
  4. class FigureRookTest
  5. {
  6. // weißer Turm
  7. @Test
  8. void whiteRookValidMoveUp()
  9. {
  10. Figure f = new FigureRook();
  11. assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4,
  12. Figure.fieldLength * 0 + 4,
  13. new Figure[Figure.fieldLength * Figure.fieldLength]));
  14. }
  15. @Test
  16. void whiteRookValidMoveDown()
  17. {
  18. Figure f = new FigureRook();
  19. assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4,
  20. Figure.fieldLength * 7 + 4,
  21. new Figure[Figure.fieldLength * Figure.fieldLength]));
  22. }
  23. @Test
  24. void whiteRookInvalidMoveLeftUp() // diagonal nach links oben
  25. {
  26. Figure f = new FigureRook();
  27. assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4,
  28. Figure.fieldLength * 3 + 3,
  29. new Figure[Figure.fieldLength * Figure.fieldLength]));
  30. }
  31. @Test
  32. void whiteRookInvalidMoveRightUp() // diagonal nach rechts oben
  33. {
  34. Figure f = new FigureRook();
  35. assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4,
  36. Figure.fieldLength * 3 + 5,
  37. new Figure[Figure.fieldLength * Figure.fieldLength]));
  38. }
  39. @Test
  40. void whiteRookInvalidMoveLeftDown() // diagonal nach links unten
  41. {
  42. Figure f = new FigureRook();
  43. assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4,
  44. Figure.fieldLength * 5 + 3,
  45. new Figure[Figure.fieldLength * Figure.fieldLength]));
  46. }
  47. @Test
  48. void whiteRookInvalidMoveRightDown() // diagonal nach rechts unten
  49. {
  50. Figure f = new FigureRook();
  51. assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4,
  52. Figure.fieldLength * 5 + 5,
  53. new Figure[Figure.fieldLength * Figure.fieldLength]));
  54. }
  55. }