Browse Source

Aktualisieren test/Pong/test_checkCollision.c

remotes/origin/branchJulia
fdai8040 11 months ago
parent
commit
0169f259dc
  1. 25
      test/Pong/test_checkCollision.c

25
test/Pong/test_checkCollision.c

@ -2,6 +2,19 @@
#include "unity.h"
#include "pong.h"
typedef struct {
int x;
int y;
int speedX;
int speedY;
} Ball;
typedef struct {
int x;
int y;
int width;
int height;
} Paddle;
void setUp(void){
//Wenn Funktion Vorraussetzungen braucht
@ -16,32 +29,32 @@ void test_checkCollision(void){
// Test Ball trifft rechte und linke Wand
ball.x = 0;
int result1 = checkCollision(&ball, &paddle);
int result1 = checkCollision(ball, paddle.y, paddle.y);
TEST_ASSERT_EQUAL_INT(1, result1);
ball.x = WIDTH - 1;
int result2 = checkCollision(&ball, &paddle);
int result2 = checkCollision(ball, paddle.y, paddle.y);
TEST_ASSERT_EQUAL_INT(1, result2);
// Test Ball trifft obere und untere Wand
ball.x = 5;
ball.y = 0;
int result3 = checkCollision(&ball, &paddle);
int result3 = checkCollision(ball, paddle.y, paddle.y);
TEST_ASSERT_EQUAL_INT(0, result3);
ball.y = HEIGHT - 1;
int result4 = checkCollision(&ball, &paddle);
int result4 = checkCollision(ball, paddle.y, paddle.y);
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);
int result5 = checkCollision(ball, paddle.y, paddle.y);
TEST_ASSERT_EQUAL_INT(0, result5);
ball.x = paddle.x + 1;
ball.y = paddle.y + 1;
int result6 = checkCollision(&ball, &paddle);
int result6 = checkCollision(ball, paddle.y, paddle.y);
TEST_ASSERT_EQUAL_INT(0, result6);
}

Loading…
Cancel
Save