Unify the library on an akgl_ namespace

This commit is contained in:
2026-05-06 23:18:42 -04:00
parent f416cb5dee
commit 359ae23414
46 changed files with 1327 additions and 1270 deletions

View File

@@ -2,15 +2,15 @@
#include <akerror.h>
#include <sdl3game/util.h>
akerr_ErrorContext *test_rectangle_points_nullpointers(void)
akerr_ErrorContext *test_akgl_rectangle_points_nullpointers(void)
{
RectanglePoints points;
SDL_FRect testrect;
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, rectangle_points(NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with all NULL pointers");
CATCH(errctx, akgl_rectangle_points(NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_rectangle_points fails to FAIL with all NULL pointers");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -18,8 +18,8 @@ akerr_ErrorContext *test_rectangle_points_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, rectangle_points(NULL, &testrect));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL SDL_FRect pointer");
CATCH(errctx, akgl_rectangle_points(NULL, &testrect));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_rectangle_points fails to FAIL with NULL SDL_FRect pointer");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -27,8 +27,8 @@ akerr_ErrorContext *test_rectangle_points_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, rectangle_points(&points, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "rectangle_points fails to FAIL with NULL RectanglePoints pointer");
CATCH(errctx, akgl_rectangle_points(&points, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_rectangle_points fails to FAIL with NULL RectanglePoints pointer");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -36,7 +36,7 @@ akerr_ErrorContext *test_rectangle_points_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, rectangle_points(&points, &testrect));
CATCH(errctx, akgl_rectangle_points(&points, &testrect));
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
@@ -44,7 +44,7 @@ akerr_ErrorContext *test_rectangle_points_nullpointers(void)
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *test_rectangle_points_math(void)
akerr_ErrorContext *test_akgl_rectangle_points_math(void)
{
RectanglePoints points;
SDL_FRect testrect = {.x = 0, .y = 0, .w = 32, .h = 32};
@@ -52,7 +52,7 @@ akerr_ErrorContext *test_rectangle_points_math(void)
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, rectangle_points(&points, &testrect));
CATCH(errctx, akgl_rectangle_points(&points, &testrect));
if ( points.topleft.x != 0 ||
points.topleft.y != 0 ||
points.topright.x != 32 ||
@@ -64,7 +64,7 @@ akerr_ErrorContext *test_rectangle_points_math(void)
FAIL_BREAK(
errctx,
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}}",
"akgl_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,
points.bottomleft.x, points.bottomleft.y,
@@ -77,7 +77,7 @@ akerr_ErrorContext *test_rectangle_points_math(void)
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
akerr_ErrorContext *test_akgl_collide_point_rectangle_nullpointers(void)
{
point testpoint;
RectanglePoints testrectpoints;
@@ -86,8 +86,8 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(*, *, NULL) failed");
CATCH(errctx, akgl_collide_point_rectangle(&testpoint, &testrectpoints, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_point_rectangle(*, *, NULL) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -95,8 +95,8 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_point_rectangle(&testpoint, NULL, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(*, NULL, *) failed");
CATCH(errctx, akgl_collide_point_rectangle(&testpoint, NULL, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_point_rectangle(*, NULL, *) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -104,8 +104,8 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_point_rectangle(NULL, &testrectpoints, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(NULL, *, *) failed");
CATCH(errctx, akgl_collide_point_rectangle(NULL, &testrectpoints, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_point_rectangle(NULL, *, *) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -113,8 +113,8 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_point_rectangle(NULL, NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_point_rectangle(NULL, NULL, NULL) failed");
CATCH(errctx, akgl_collide_point_rectangle(NULL, NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_point_rectangle(NULL, NULL, NULL) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -122,7 +122,7 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
CATCH(errctx, akgl_collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
@@ -130,7 +130,7 @@ akerr_ErrorContext *test_collide_point_rectangle_nullpointers(void)
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *test_collide_point_rectangle_logic(void)
akerr_ErrorContext *test_akgl_collide_point_rectangle_logic(void)
{
point testpoint = {.x = 16, .y = 16};
SDL_FRect testrect = { .x = 0, .y = 0, .w = 32, .h = 32};
@@ -139,15 +139,15 @@ akerr_ErrorContext *test_collide_point_rectangle_logic(void)
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, rectangle_points(&testrectpoints, &testrect));
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
CATCH(errctx, akgl_rectangle_points(&testrectpoints, &testrect));
CATCH(errctx, akgl_collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
testpoint.x = 48;
testpoint.y = 48;
CATCH(errctx, collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
CATCH(errctx, akgl_collide_point_rectangle(&testpoint, &testrectpoints, &testcollide));
if ( testcollide == true ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Invalid collision reported");
}
@@ -157,7 +157,7 @@ akerr_ErrorContext *test_collide_point_rectangle_logic(void)
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
akerr_ErrorContext *test_akgl_collide_rectangles_nullpointers(void)
{
SDL_FRect testrect1;
SDL_FRect testrect2;
@@ -166,8 +166,8 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(*, *, NULL) failed");
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_rectangles(*, *, NULL) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -175,8 +175,8 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_rectangles(&testrect1, NULL, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(*, NULL, *) failed");
CATCH(errctx, akgl_collide_rectangles(&testrect1, NULL, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_rectangles(*, NULL, *) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -184,8 +184,8 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_rectangles(NULL, &testrect2, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(NULL, *, *) failed");
CATCH(errctx, akgl_collide_rectangles(NULL, &testrect2, &testcollide));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_rectangles(NULL, *, *) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -193,8 +193,8 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_rectangles(NULL, NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "collide_rectangles(NULL, NULL, NULL) failed");
CATCH(errctx, akgl_collide_rectangles(NULL, NULL, NULL));
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "akgl_collide_rectangles(NULL, NULL, NULL) failed");
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
@@ -202,7 +202,7 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
} FINISH(errctx, true);
ATTEMPT {
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
@@ -210,7 +210,7 @@ akerr_ErrorContext *test_collide_rectangles_nullpointers(void)
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *test_collide_rectangles_logic(void)
akerr_ErrorContext *test_akgl_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};
@@ -220,14 +220,14 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
ATTEMPT {
// Collision overlapping on the top left
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
// Collision overlapping on the top right
testrect1.x = 64;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -235,7 +235,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
// Collision overlapping on the bottom left
testrect1.x = 0;
testrect1.y = 32;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -243,7 +243,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
// Collision overlapping on the bottom right
testrect1.x = 32;
testrect1.y = 32;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -253,7 +253,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
testrect1.y = 0;
testrect1.w = 60;
testrect1.h = 32;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -263,7 +263,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
testrect1.y = 0;
testrect1.w = 35;
testrect1.h = 80;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -273,7 +273,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
testrect1.y = 0;
testrect1.w = 60;
testrect1.h = 80;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -283,7 +283,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
testrect1.y = 65;
testrect1.w = 80;
testrect1.h = 32;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == false ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Valid collision missed");
}
@@ -293,7 +293,7 @@ akerr_ErrorContext *test_collide_rectangles_logic(void)
testrect1.y = 0;
testrect1.w = 16;
testrect1.h = 16;
CATCH(errctx, collide_rectangles(&testrect1, &testrect2, &testcollide));
CATCH(errctx, akgl_collide_rectangles(&testrect1, &testrect2, &testcollide));
if ( testcollide == true ) {
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Invalid collision reported");
}
@@ -309,11 +309,11 @@ int main(void)
{
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, test_rectangle_points_nullpointers());
CATCH(errctx, test_rectangle_points_math());
CATCH(errctx, test_collide_point_rectangle_nullpointers());
CATCH(errctx, test_collide_rectangles_nullpointers());
CATCH(errctx, test_collide_rectangles_logic());
CATCH(errctx, test_akgl_rectangle_points_nullpointers());
CATCH(errctx, test_akgl_rectangle_points_math());
CATCH(errctx, test_akgl_collide_point_rectangle_nullpointers());
CATCH(errctx, test_akgl_collide_rectangles_nullpointers());
CATCH(errctx, test_akgl_collide_rectangles_logic());
} CLEANUP {
} PROCESS(errctx) {
} FINISH_NORETURN(errctx);