From 9729861429297a99a24d1600b07b278f0954d375 Mon Sep 17 00:00:00 2001 From: fdai8040 Date: Sat, 3 Feb 2024 16:40:02 +0000 Subject: [PATCH] Aktualisieren test/Pong/test_checkCollision.c --- test/Pong/test_checkCollision.c | 39 +++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/test/Pong/test_checkCollision.c b/test/Pong/test_checkCollision.c index 12dac8a..ab2a4fa 100644 --- a/test/Pong/test_checkCollision.c +++ b/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