Browse Source

test_updateBallPosition

remotes/origin/branchJulia
fdai8040 11 months ago
parent
commit
c3ab68b1de
  1. 30
      test/Pong/test_updateBallPosition.c

30
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
Loading…
Cancel
Save