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.

49 lines
1.0 KiB

#ifdef TEST
#include "unity.h"
#include "SchereSteinPapier.h"
#include <stdlib.h>
void setUp(void)
{
}
void tearDown(void)
{
}
void test_Scheresteinpapier_generateRandom(void) {
srand(42);
for (int i = 0; i < 100; ++i) {
int result = generateRandom();
TEST_ASSERT_TRUE(result >= 0 && result <= 2);
}
}
void test_Scheresteinpapier_determineWinner(void) {
for (int spieler = 0; spieler <= 2; ++spieler) {
for (int computer = 0; computer <= 2; ++computer) {
int result = determineWinner(spieler, computer);
if ((spieler == 0 && computer == 2) ||
(spieler == 1 && computer == 0) ||
(spieler == 2 && computer == 1)) {
TEST_ASSERT_EQUAL(1, result); // Spieler gewinnt
}
else if (spieler == computer) {
TEST_ASSERT_EQUAL(0, result); // Unentschieden
}
else {
TEST_ASSERT_EQUAL(-1, result); // Computer gewinnt
}
}
}
}
#endif // TEST