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.

47 lines
1.0 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "SchereSteinPapier.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_Scheresteinpapier_generateRandom(void) {
  11. srand(42);
  12. for (int i = 0; i < 100; ++i) {
  13. int result = generateRandom();
  14. TEST_ASSERT_TRUE(result >= 0 && result <= 2);
  15. }
  16. }
  17. void test_Scheresteinpapier_determineWinner(void) {
  18. for (int spieler = 0; spieler <= 2; ++spieler) {
  19. for (int computer = 0; computer <= 2; ++computer) {
  20. int result = determineWinner(spieler, computer);
  21. if ((spieler == 0 && computer == 2) ||
  22. (spieler == 1 && computer == 0) ||
  23. (spieler == 2 && computer == 1)) {
  24. TEST_ASSERT_EQUAL(1, result); // Spieler gewinnt
  25. }
  26. else if (spieler == computer) {
  27. TEST_ASSERT_EQUAL(0, result); // Unentschieden
  28. }
  29. else {
  30. TEST_ASSERT_EQUAL(-1, result); // Computer gewinnt
  31. }
  32. }
  33. }
  34. }
  35. #endif // TEST