Reindent all C sources to the canonical stroustrup style
Mechanical whitespace-only change across src/, include/, tests/, and util/, applied with scripts/reindent.sh. No behavioral change. Most files already conformed. The genuine outliers indented at 2 columns (json_helpers.c, util.c from akgl_rectangle_points onward, assets.c, staticstring.c, akgl_actor_add_child, util.h, staticstring.h) or used spaces where the canonical form is a tab (draw.c). cc-mode also re-aligns line-continuation backslashes in multi-line macros to its default c-backslash-column, which is required for the tree to be a fixed point of the indenter. Verified whitespace-only: `git diff -w` over this change is empty apart from three trailing blank lines removed at EOF in src/heap.c, src/registry.c, and tests/tilemap.c. The build produces no new errors and ctest is unchanged at 13/14, with `character` still the one intentional failure. The tree is now a fixed point of `scripts/reindent.sh --check`. include/akgl/SDL_GameControllerDB.h is generated and excluded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
228
tests/sprite.c
228
tests/sprite.c
@@ -16,53 +16,53 @@
|
||||
|
||||
akerr_ErrorContext *test_akgl_spritesheet_initialize(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
akgl_SpriteSheet *sheet = NULL;
|
||||
SDL_Texture *image = NULL;
|
||||
akgl_String *tmpstr = NULL;
|
||||
// Does the image file get loaded?
|
||||
// Is the image file loaded correctly? (Surface comparison)
|
||||
// Is the spritesheet in the registry?
|
||||
ATTEMPT {
|
||||
CATCH(errctx, akgl_heap_next_spritesheet(&sheet));
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
CATCH(errctx, akgl_spritesheet_initialize(sheet, 48, 48, "assets/spritesheet.png"));
|
||||
FAIL_ZERO_BREAK(errctx, sheet->texture, AKERR_VALUE, "akgl_spritesheet_initialize failed to load the sprite texture");
|
||||
FAIL_NONZERO_BREAK(
|
||||
errctx,
|
||||
((sheet->texture->w != 576) || (sheet->texture->h != 384)),
|
||||
AKERR_VALUE,
|
||||
"Loaded texture was not the correct size");
|
||||
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
image = IMG_LoadTexture(renderer->sdl_renderer, (char *)&tmpstr->data);
|
||||
FAIL_ZERO_BREAK(errctx, image, AKGL_ERR_SDL, "Failed to load comparison image");
|
||||
PREPARE_ERROR(errctx);
|
||||
akgl_SpriteSheet *sheet = NULL;
|
||||
SDL_Texture *image = NULL;
|
||||
akgl_String *tmpstr = NULL;
|
||||
// Does the image file get loaded?
|
||||
// Is the image file loaded correctly? (Surface comparison)
|
||||
// Is the spritesheet in the registry?
|
||||
ATTEMPT {
|
||||
CATCH(errctx, akgl_heap_next_spritesheet(&sheet));
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
CATCH(
|
||||
errctx,
|
||||
akgl_render_and_compare(
|
||||
sheet->texture,
|
||||
image,
|
||||
0, 0, 576, 384,
|
||||
"test_spritesheet_loaded_image.png")
|
||||
);
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
CATCH(errctx, akgl_spritesheet_initialize(sheet, 48, 48, "assets/spritesheet.png"));
|
||||
FAIL_ZERO_BREAK(errctx, sheet->texture, AKERR_VALUE, "akgl_spritesheet_initialize failed to load the sprite texture");
|
||||
FAIL_NONZERO_BREAK(
|
||||
errctx,
|
||||
((sheet->texture->w != 576) || (sheet->texture->h != 384)),
|
||||
AKERR_VALUE,
|
||||
"Loaded texture was not the correct size");
|
||||
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
SDL_GetPointerProperty(AKGL_REGISTRY_SPRITESHEET, "assets/spritesheet.png", NULL),
|
||||
AKERR_KEY,
|
||||
"Spritesheet was not placed in the registry");
|
||||
|
||||
} CLEANUP {
|
||||
IGNORE(akgl_heap_release_string(tmpstr));
|
||||
IGNORE(akgl_heap_release_spritesheet(sheet));
|
||||
if ( image != NULL )
|
||||
SDL_DestroyTexture(image);
|
||||
} PROCESS(errctx) {
|
||||
} FINISH(errctx, true);
|
||||
SUCCEED_RETURN(errctx);
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
image = IMG_LoadTexture(renderer->sdl_renderer, (char *)&tmpstr->data);
|
||||
FAIL_ZERO_BREAK(errctx, image, AKGL_ERR_SDL, "Failed to load comparison image");
|
||||
|
||||
CATCH(
|
||||
errctx,
|
||||
akgl_render_and_compare(
|
||||
sheet->texture,
|
||||
image,
|
||||
0, 0, 576, 384,
|
||||
"test_spritesheet_loaded_image.png")
|
||||
);
|
||||
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
SDL_GetPointerProperty(AKGL_REGISTRY_SPRITESHEET, "assets/spritesheet.png", NULL),
|
||||
AKERR_KEY,
|
||||
"Spritesheet was not placed in the registry");
|
||||
|
||||
} CLEANUP {
|
||||
IGNORE(akgl_heap_release_string(tmpstr));
|
||||
IGNORE(akgl_heap_release_spritesheet(sheet));
|
||||
if ( image != NULL )
|
||||
SDL_DestroyTexture(image);
|
||||
} PROCESS(errctx) {
|
||||
} FINISH(errctx, true);
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *test_akgl_sprite_initialize(void)
|
||||
@@ -71,28 +71,28 @@ akerr_ErrorContext *test_akgl_sprite_initialize(void)
|
||||
akgl_SpriteSheet *testsheet = NULL;
|
||||
akgl_Sprite *testsprite = NULL;
|
||||
akgl_String *tmpstr = NULL;
|
||||
|
||||
|
||||
// Does the sprite get loaded?
|
||||
// Do all frames of the sprite get loaded?
|
||||
// Are all the frames of the sprite what we expect? (Surface comparison)
|
||||
// Is the sprite added to the registry?
|
||||
ATTEMPT {
|
||||
CATCH(errctx, akgl_heap_next_spritesheet(&testsheet));
|
||||
CATCH(errctx, akgl_heap_next_sprite(&testsprite));
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
CATCH(errctx, akgl_spritesheet_initialize(testsheet, 48, 48, "assets/spritesheet.png"));
|
||||
FAIL_ZERO_BREAK(errctx, testsheet, AKERR_VALUE, "akgl_spritesheet_initialize failed");
|
||||
CATCH(errctx, akgl_heap_next_spritesheet(&testsheet));
|
||||
CATCH(errctx, akgl_heap_next_sprite(&testsprite));
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
CATCH(errctx, akgl_spritesheet_initialize(testsheet, 48, 48, "assets/spritesheet.png"));
|
||||
FAIL_ZERO_BREAK(errctx, testsheet, AKERR_VALUE, "akgl_spritesheet_initialize failed");
|
||||
|
||||
CATCH(errctx, akgl_sprite_initialize(testsprite, "test", testsheet));
|
||||
FAIL_NONZERO_BREAK(errctx, (testsprite->sheet != testsheet), AKERR_VALUE, "Initialized sprite uses wrong sheet");
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "test", NULL),
|
||||
AKERR_KEY,
|
||||
"Sprite was not placed in the registry");
|
||||
|
||||
CATCH(errctx, akgl_sprite_initialize(testsprite, "test", testsheet));
|
||||
FAIL_NONZERO_BREAK(errctx, (testsprite->sheet != testsheet), AKERR_VALUE, "Initialized sprite uses wrong sheet");
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "test", NULL),
|
||||
AKERR_KEY,
|
||||
"Sprite was not placed in the registry");
|
||||
|
||||
} CLEANUP {
|
||||
IGNORE(akgl_heap_release_sprite(testsprite));
|
||||
IGNORE(akgl_heap_release_string(tmpstr));
|
||||
@@ -108,65 +108,65 @@ akerr_ErrorContext *test_akgl_sprite_load_json(void)
|
||||
akgl_Sprite *testsprite2 = NULL;
|
||||
akgl_String *tmpstr = NULL;
|
||||
SDL_Texture *image = NULL;
|
||||
|
||||
|
||||
// Does the sprite get loaded?
|
||||
// Do all frames of the sprite get loaded?
|
||||
// Are all the frames of the sprite what we expect? (Surface comparison)
|
||||
// Is the sprite added to the registry?
|
||||
ATTEMPT {
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
CATCH(errctx, akgl_sprite_load_json("assets/testsprite.json"));
|
||||
testsprite = SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "testsprite", NULL);
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
testsprite,
|
||||
AKERR_KEY,
|
||||
"akgl_sprite_load_json succeeds but sprite is not placed in the registry");
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->width == 48), AKERR_VALUE, "width incorrect (48 : %d)", testsprite->width);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->height == 48), AKERR_VALUE, "height incorrect (48 : %d)", testsprite->height);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->speed == 100000000), AKERR_VALUE, "speed incorrect (100 : %d)", testsprite->speed);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->loop == true), AKERR_VALUE, "loop incorrect (1 : %d)", testsprite->loop);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->loopReverse == true), AKERR_VALUE, "loopReverse incorrect (1 : %d)", testsprite->loopReverse);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frames == 3), AKERR_VALUE, "frame count incorrect (3 : %d)", testsprite->frames);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[0] == 12), AKERR_VALUE, "frameids[0] incorrect (12 : %d)", testsprite->frameids[0]);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[1] == 13), AKERR_VALUE, "frameids[1] incorrect (13 : %d)", testsprite->frameids[1]);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[2] == 14), AKERR_VALUE, "frameids[2] incorrect (14 : %d)", testsprite->frameids[2]);
|
||||
FAIL_NONZERO_BREAK(errctx, strcmp(testsprite->name, "testsprite"), AKERR_VALUE, "name incorrect (testsprite : %s)", (char *)testsprite->name);
|
||||
CATCH(errctx, akgl_sprite_load_json("assets/testsprite.json"));
|
||||
testsprite = SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "testsprite", NULL);
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
testsprite,
|
||||
AKERR_KEY,
|
||||
"akgl_sprite_load_json succeeds but sprite is not placed in the registry");
|
||||
|
||||
// Is it using the right spritesheet?
|
||||
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
image = IMG_LoadTexture(renderer->sdl_renderer, (char *)&tmpstr->data);
|
||||
FAIL_ZERO_BREAK(errctx, image, AKGL_ERR_SDL, "Failed to load comparison image");
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->width == 48), AKERR_VALUE, "width incorrect (48 : %d)", testsprite->width);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->height == 48), AKERR_VALUE, "height incorrect (48 : %d)", testsprite->height);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->speed == 100000000), AKERR_VALUE, "speed incorrect (100 : %d)", testsprite->speed);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->loop == true), AKERR_VALUE, "loop incorrect (1 : %d)", testsprite->loop);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->loopReverse == true), AKERR_VALUE, "loopReverse incorrect (1 : %d)", testsprite->loopReverse);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frames == 3), AKERR_VALUE, "frame count incorrect (3 : %d)", testsprite->frames);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[0] == 12), AKERR_VALUE, "frameids[0] incorrect (12 : %d)", testsprite->frameids[0]);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[1] == 13), AKERR_VALUE, "frameids[1] incorrect (13 : %d)", testsprite->frameids[1]);
|
||||
FAIL_ZERO_BREAK(errctx, (testsprite->frameids[2] == 14), AKERR_VALUE, "frameids[2] incorrect (14 : %d)", testsprite->frameids[2]);
|
||||
FAIL_NONZERO_BREAK(errctx, strcmp(testsprite->name, "testsprite"), AKERR_VALUE, "name incorrect (testsprite : %s)", (char *)testsprite->name);
|
||||
|
||||
CATCH(
|
||||
errctx,
|
||||
akgl_render_and_compare(
|
||||
testsprite->sheet->texture,
|
||||
image,
|
||||
0, 0, 576, 384,
|
||||
"test_sprite_loaded_from_json_sheet.png"
|
||||
)
|
||||
);
|
||||
// Is it using the right spritesheet?
|
||||
|
||||
// If we load a second sprite using the same sheet name, do they use the same sheet in memory?
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/testsprite2.json");
|
||||
CATCH(errctx, akgl_sprite_load_json("assets/testsprite2.json"));
|
||||
testsprite2 = SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "testsprite2", NULL);
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
testsprite,
|
||||
AKERR_KEY,
|
||||
"akgl_sprite_load_json succeeds but second sprite is not placed in the registry");
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/spritesheet.png");
|
||||
image = IMG_LoadTexture(renderer->sdl_renderer, (char *)&tmpstr->data);
|
||||
FAIL_ZERO_BREAK(errctx, image, AKGL_ERR_SDL, "Failed to load comparison image");
|
||||
|
||||
CATCH(
|
||||
errctx,
|
||||
akgl_render_and_compare(
|
||||
testsprite->sheet->texture,
|
||||
image,
|
||||
0, 0, 576, 384,
|
||||
"test_sprite_loaded_from_json_sheet.png"
|
||||
)
|
||||
);
|
||||
|
||||
// If we load a second sprite using the same sheet name, do they use the same sheet in memory?
|
||||
snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), "assets/testsprite2.json");
|
||||
CATCH(errctx, akgl_sprite_load_json("assets/testsprite2.json"));
|
||||
testsprite2 = SDL_GetPointerProperty(AKGL_REGISTRY_SPRITE, "testsprite2", NULL);
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
testsprite,
|
||||
AKERR_KEY,
|
||||
"akgl_sprite_load_json succeeds but second sprite is not placed in the registry");
|
||||
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
(testsprite->sheet == testsprite2->sheet),
|
||||
AKERR_VALUE,
|
||||
"Previously loaded spritesheets are not reused");
|
||||
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
(testsprite->sheet == testsprite2->sheet),
|
||||
AKERR_VALUE,
|
||||
"Previously loaded spritesheets are not reused");
|
||||
|
||||
} CLEANUP {
|
||||
if ( testsprite != NULL ) {
|
||||
IGNORE(akgl_heap_release_sprite(testsprite));
|
||||
@@ -185,16 +185,16 @@ akerr_ErrorContext *test_akgl_sprite_load_json(void)
|
||||
int main(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
|
||||
ATTEMPT {
|
||||
renderer = &_akgl_renderer;
|
||||
|
||||
|
||||
SDL_SetAppMetadata("SDL3-GameTest", "0.1", "net.aklabs.sdl3-gametest");
|
||||
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO )) {
|
||||
FAIL_BREAK(errctx, AKGL_ERR_SDL, "Couldn't initialize SDL: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
|
||||
if (!SDL_CreateWindowAndRenderer("net/aklabs/libakgl/test_sprite", 640, 480, 0, &window, &renderer->sdl_renderer)) {
|
||||
FAIL_BREAK(errctx, AKGL_ERR_SDL, "Couldn't create window/renderer: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user