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.

53 lines
1.7 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 static org.junit.jupiter.api.Assertions.*;
  6. class FigureFarmerTest
  7. {
  8. Figure[] field = new Figure[Figure.fieldLength * Figure.fieldLength];
  9. // weißer Bauer
  10. @ParameterizedTest
  11. // row (src), col (src), row (dst), col (dst)
  12. @CsvSource({
  13. "6, 0, 5, 0", // a2 -> a3
  14. "4, 4, 3, 4" // e4 -> e5
  15. })
  16. void whiteFarmerValidDestination(int srcRow, int srcCol, int dstRow, int dstCol)
  17. {
  18. int src = Figure.fieldLength * srcRow + srcCol;
  19. int dst = Figure.fieldLength * dstRow + dstCol;
  20. Figure f = new FigureFarmer(FigureFarmer.Color.White);
  21. assertTrue(f.moveAllowed(src, dst, field));
  22. }
  23. // weißer Bauer
  24. @ParameterizedTest
  25. // row (src), col (src), row (dst), col (dst)
  26. @CsvSource({
  27. "6, 0, 7, 0", // a2 -> a1
  28. "4, 4, 5, 4" // e4 -> e3
  29. })
  30. void whiteFarmerInvalidDestinationDown(int srcRow, int srcCol, int dstRow, int dstCol) // statt nach "oben" wird nach "unten" gegangen
  31. {
  32. int src = Figure.fieldLength * srcRow + srcCol;
  33. int dst = Figure.fieldLength * dstRow + dstCol;
  34. Figure f = new FigureFarmer(FigureFarmer.Color.White);
  35. assertFalse(f.moveAllowed(src, dst, field));
  36. }
  37. @Test
  38. void whiteFarmerInvalidDestinationUp() // mehr als 1 Schritt nach "oben"
  39. {
  40. int src = Figure.fieldLength * 6 + 0;
  41. int dst = Figure.fieldLength * 4 + 0;
  42. Figure f = new FigureFarmer(FigureFarmer.Color.White);
  43. assertFalse(f.moveAllowed(src, dst, field));
  44. }
  45. }