Got the suite rebuilding, most tests pass, actor and sprite are failing
This commit is contained in:
80
tests/util.c
80
tests/util.c
@@ -2,7 +2,7 @@
|
||||
#include <akerror.h>
|
||||
#include <sdl3game/util.h>
|
||||
|
||||
ErrorContext *test_rectangle_points_nullpointers(void)
|
||||
akerr_ErrorContext *test_rectangle_points_nullpointers(void)
|
||||
{
|
||||
RectanglePoints points;
|
||||
SDL_FRect testrect;
|
||||
@@ -10,28 +10,28 @@ ErrorContext *test_rectangle_points_nullpointers(void)
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, rectangle_points(NULL, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "rectangle_points fails to FAIL with all NULL pointers");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with all NULL pointers");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, rectangle_points(NULL, &testrect));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL SDL_FRect pointer");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL SDL_FRect pointer");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, rectangle_points(&points, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL RectanglePoints pointer");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL RectanglePoints pointer");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
@@ -44,7 +44,7 @@ ErrorContext *test_rectangle_points_nullpointers(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_rectangle_points_math(void)
|
||||
akerr_ErrorContext *test_rectangle_points_math(void)
|
||||
{
|
||||
RectanglePoints points;
|
||||
SDL_FRect testrect = {.x = 0, .y = 0, .w = 32, .h = 32};
|
||||
@@ -63,7 +63,7 @@ ErrorContext *test_rectangle_points_math(void)
|
||||
points.bottomright.y != 32 ) {
|
||||
FAIL_BREAK(
|
||||
errctx,
|
||||
ERR_BEHAVIOR,
|
||||
AKERR_BEHAVIOR,
|
||||
"rectangle_points incorrectly calculated points for {x=0, y=0, w=32, h=32} to {topleft={%d, %d}, topright={%d, %d}, bottomleft={%d, %d}, bottomright={%d, %d}}",
|
||||
points.topleft.x, points.topleft.y,
|
||||
points.topright.x, points.topright.y,
|
||||
@@ -77,7 +77,7 @@ ErrorContext *test_rectangle_points_math(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_collide_point_rectangle_nullpointers(void)
|
||||
akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
|
||||
{
|
||||
point testpoint;
|
||||
RectanglePoints testrectpoints;
|
||||
@@ -87,37 +87,37 @@ ErrorContext *test_collide_point_rectangle_nullpointers(void)
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_point_rectangle(*, *, NULL) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(*, *, NULL) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_point_rectangle(&testpoint, NULL, &testcollide));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_point_rectangle(*, NULL, *) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(*, NULL, *) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_point_rectangle(NULL, &testrectpoints, &testcollide));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_point_rectangle(NULL, *, *) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(NULL, *, *) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_point_rectangle(NULL, NULL, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_point_rectangle(NULL, NULL, NULL) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(NULL, NULL, NULL) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
@@ -130,7 +130,7 @@ ErrorContext *test_collide_point_rectangle_nullpointers(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_collide_point_rectangle_logic(void)
|
||||
akerr_ErrorContext *test_collide_point_rectangle_logic(void)
|
||||
{
|
||||
point testpoint = {.x = 16, .y = 16};
|
||||
SDL_FRect testrect = { .x = 0, .y = 0, .w = 32, .h = 32};
|
||||
@@ -142,14 +142,14 @@ ErrorContext *test_collide_point_rectangle_logic(void)
|
||||
CATCH(errctx, rectangle_points(&testrectpoints, &testrect));
|
||||
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
testpoint.x = 48;
|
||||
testpoint.y = 48;
|
||||
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
|
||||
if ( testcollide == true ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Invalid collision reported");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Invalid collision reported");
|
||||
}
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
@@ -157,7 +157,7 @@ ErrorContext *test_collide_point_rectangle_logic(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_collide_rectangles_nullpointers(void)
|
||||
akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
|
||||
{
|
||||
SDL_FRect testrect1;
|
||||
SDL_FRect testrect2;
|
||||
@@ -167,37 +167,37 @@ ErrorContext *test_collide_rectangles_nullpointers(void)
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_rectangles(*, *, NULL) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(*, *, NULL) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_rectangles(&testrect1, NULL, &testcollide));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_rectangles(*, NULL, *) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(*, NULL, *) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_rectangles(NULL, &testrect2, &testcollide));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_rectangles(NULL, *, *) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(NULL, *, *) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, collide_rectangles(NULL, NULL, NULL));
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "collide_rectangles(NULL, NULL, NULL) failed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(NULL, NULL, NULL) failed");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
// noop
|
||||
} FINISH(errctx, true);
|
||||
|
||||
@@ -210,7 +210,7 @@ ErrorContext *test_collide_rectangles_nullpointers(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_collide_rectangles_logic(void)
|
||||
akerr_ErrorContext *test_collide_rectangles_logic(void)
|
||||
{
|
||||
SDL_FRect testrect1 = { .x = 0, .y = 0, .w = 32, .h = 32};
|
||||
SDL_FRect testrect2 = { .x = 30, .y = 30, .w = 40, .h = 40};
|
||||
@@ -222,14 +222,14 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
// Collision overlapping on the top left
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping on the top right
|
||||
testrect1.x = 64;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping on the bottom left
|
||||
@@ -237,7 +237,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.y = 32;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping on the bottom right
|
||||
@@ -245,7 +245,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.y = 32;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping the top edge
|
||||
@@ -255,7 +255,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.h = 32;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping the left edge
|
||||
@@ -265,7 +265,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.h = 80;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping the right edge
|
||||
@@ -275,7 +275,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.h = 80;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Collision overlapping the bottom edge
|
||||
@@ -285,7 +285,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.h = 32;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == false ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Valid collision missed");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
|
||||
}
|
||||
|
||||
// Not colliding
|
||||
@@ -295,7 +295,7 @@ ErrorContext *test_collide_rectangles_logic(void)
|
||||
testrect1.h = 16;
|
||||
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
|
||||
if ( testcollide == true ) {
|
||||
FAIL_BREAK(errctx, ERR_BEHAVIOR, "Invalid collision reported");
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Invalid collision reported");
|
||||
}
|
||||
|
||||
} CLEANUP {
|
||||
|
||||
Reference in New Issue
Block a user