From c3ab68b1dece08dff9ae9667360706fa3fbbaa49 Mon Sep 17 00:00:00 2001 From: fdai8040 Date: Sat, 3 Feb 2024 16:07:52 +0000 Subject: [PATCH] test_updateBallPosition --- test/Pong/test_updateBallPosition.c | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/Pong/test_updateBallPosition.c 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