diff --git a/test/Pong/test_updateBallPosition.c b/test/Pong/test_updateBallPosition.c new file mode 100644 index 0000000..5894273 --- /dev/null +++ b/test/Pong/test_updateBallPosition.c @@ -0,0 +1,30 @@ +#ifdef TEST +#include "unity.h" +#include "pong.h" + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} + +void tearDown(void){ +} + +void test_updateBallPosition(void){ + /* arrange */ + Ball ball = { 10, 10, 1, 1 }; + int expectedX = ball.x + ball.speedX * 5; // erwartete Endposition nach 5 Schritten + int expectedY = ball.y + ball.speedY * 5; + + /* act */ + updateBallPosition(&ball); + updateBallPosition(&ball); + updateBallPosition(&ball); + updateBallPosition(&ball); + updateBallPosition(&ball); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expectedX, ball.x); + TEST_ASSERT_EQUAL_INT(expectedY, ball.y); +} + +#endif // TEST