Browse Source

Aktualisieren test/Pong/test_checkCollision.c

remotes/origin/branchJulia
fdai8040 11 months ago
parent
commit
9729861429
  1. 39
      test/Pong/test_checkCollision.c

39
test/Pong/test_checkCollision.c

@ -11,27 +11,38 @@ void tearDown(void){
}
void test_checkCollision(void){
/* Test 1: Ball und Schläger kollidieren nicht */
Ball ball = {10, 10, 1, 1};
Paddle paddle = {50, 10, 5, 10};
int result1 = checkCollision(ball, paddle);
TEST_ASSERT_EQUAL_INT(0, result1);
// Test Ball trifft rechte und linke Wand
ball.x = 0;
int result1 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(1, result1);
/* Test 2: Ball kollidiert mit Schläger */
ball.x = 50;
ball.y = 10;
int result2 = checkCollision(ball, paddle);
ball.x = WIDTH - 1;
int result2 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(1, result2);
/* Test 3: Ball kollidiert mit Bildschirmrand */
ball.x = 0;
// Test Ball trifft obere und untere Wand
ball.x = 5;
ball.y = 0;
int result3 = checkCollision(ball, paddle);
TEST_ASSERT_EQUAL_INT(2, result3);
/* Weitere Tests mit verschiedenen Kollisionsfällen können hinzugefügt werden */
int result3 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(0, result3);
ball.y = HEIGHT - 1;
int result4 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(0, result4);
// Test wenn Ball Paddle trifft
ball.x = paddle.x - 1;
ball.y = paddle.y + 1;
int result5 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(0, result5);
ball.x = paddle.x + 1;
ball.y = paddle.y + 1;
int result6 = checkCollision(&ball, &paddle);
TEST_ASSERT_EQUAL_INT(0, result6);
}
#endif // TEST
Loading…
Cancel
Save