|
@ -1,40 +0,0 @@ |
|
|
#ifdef TEST |
|
|
|
|
|
#include "unity.h" |
|
|
|
|
|
#include "pong.h" |
|
|
|
|
|
|
|
|
|
|
|
void updateBallPosition(Ball *ball) { |
|
|
|
|
|
|
|
|
|
|
|
ball->x += ball->speedX; |
|
|
|
|
|
ball->y += ball->speedY; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setUp(void){ |
|
|
|
|
|
//Wenn Funktion Vorraussetzungen braucht |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void tearDown(void){ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_updateBallPosition(void){ |
|
|
|
|
|
/* arrange */ |
|
|
|
|
|
Ball ball; |
|
|
|
|
|
ball.x = 10; |
|
|
|
|
|
ball.y = 10; |
|
|
|
|
|
ball.speedX = 1; |
|
|
|
|
|
ball.speedY = 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 |
|
|
|