Got the suite rebuilding, most tests pass, actor and sprite are failing
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
#include <sdl3game/heap.h>
|
||||
|
||||
int UNHANDLED_ERROR_BEHAVIOR;
|
||||
ErrorContext *unhandled_error_context;
|
||||
akerr_ErrorContext *unhandled_error_context;
|
||||
|
||||
void handle_unhandled_error_noexit(ErrorContext *errctx)
|
||||
void handle_unhandled_error_noexit(akerr_ErrorContext *errctx)
|
||||
{
|
||||
if ( errctx == NULL ) {
|
||||
return;
|
||||
@@ -33,7 +33,7 @@ void handle_unhandled_error_noexit(ErrorContext *errctx)
|
||||
}
|
||||
|
||||
int actor_updated;
|
||||
ErrorContext *actor_update_noop(actor *obj)
|
||||
akerr_ErrorContext *actor_update_noop(actor *obj)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
actor_updated = 1;
|
||||
@@ -42,44 +42,43 @@ ErrorContext *actor_update_noop(actor *obj)
|
||||
|
||||
// Currently the renderer assumes there is a global variable named `renderer`
|
||||
int actor_rendered;
|
||||
ErrorContext *actor_render_noop(actor *obj, SDL_Renderer *r)
|
||||
akerr_ErrorContext *actor_render_noop(actor *obj, SDL_Renderer *r)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
actor_rendered = 1;
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_registry_actor_iterator_nullpointers(void)
|
||||
akerr_ErrorContext *test_registry_actor_iterator_nullpointers(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
ErrorUnhandledErrorHandler defaulthandler = error_handler_unhandled_error;
|
||||
akerr_ErrorUnhandledErrorHandler defaulthandler = akerr_handler_unhandled_error;
|
||||
|
||||
error_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
akerr_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
ATTEMPT {
|
||||
UNHANDLED_ERROR_BEHAVIOR = UNHANDLED_ERROR_SET;
|
||||
DETECT(unhandled_error_context, registry_iterate_actor(NULL, REGISTRY_ACTOR, ""));
|
||||
} CLEANUP {
|
||||
UNHANDLED_ERROR_BEHAVIOR = UNHANDLED_ERROR_EXIT;
|
||||
} PROCESS(unhandled_error_context) {
|
||||
} HANDLE(unhandled_error_context, ERR_NULLPOINTER) {
|
||||
} HANDLE(unhandled_error_context, AKERR_NULLPOINTER) {
|
||||
printf("Handled\n");
|
||||
} FINISH(unhandled_error_context, true);
|
||||
IGNORE(heap_release_error(unhandled_error_context));
|
||||
error_handler_unhandled_error = defaulthandler;
|
||||
akerr_handler_unhandled_error = defaulthandler;
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_registry_actor_iterator_missingactor(void)
|
||||
akerr_ErrorContext *test_registry_actor_iterator_missingactor(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
ErrorUnhandledErrorHandler defaulthandler = error_handler_unhandled_error;
|
||||
akerr_ErrorUnhandledErrorHandler defaulthandler = akerr_handler_unhandled_error;
|
||||
|
||||
iterator iter = {
|
||||
.layerid = 0,
|
||||
.flags = 0
|
||||
};
|
||||
error_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
akerr_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
ATTEMPT {
|
||||
UNHANDLED_ERROR_BEHAVIOR = UNHANDLED_ERROR_SET;
|
||||
DETECT(
|
||||
@@ -92,25 +91,24 @@ ErrorContext *test_registry_actor_iterator_missingactor(void)
|
||||
} CLEANUP {
|
||||
UNHANDLED_ERROR_BEHAVIOR = UNHANDLED_ERROR_EXIT;
|
||||
} PROCESS(unhandled_error_context) {
|
||||
} HANDLE(unhandled_error_context, ERR_KEY) {
|
||||
} HANDLE(unhandled_error_context, AKERR_KEY) {
|
||||
printf("Handled\n");
|
||||
} FINISH(unhandled_error_context, true);
|
||||
IGNORE(heap_release_error(unhandled_error_context));
|
||||
error_handler_unhandled_error = defaulthandler;
|
||||
akerr_handler_unhandled_error = defaulthandler;
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_registry_actor_iterator_updaterender(void)
|
||||
akerr_ErrorContext *test_registry_actor_iterator_updaterender(void)
|
||||
{
|
||||
actor *testactor;
|
||||
iterator iter = {
|
||||
.layerid = 0,
|
||||
.flags = ITERATOR_OP_UPDATE | ITERATOR_OP_RENDER
|
||||
};
|
||||
ErrorUnhandledErrorHandler defaulthandler = error_handler_unhandled_error;
|
||||
akerr_ErrorUnhandledErrorHandler defaulthandler = akerr_handler_unhandled_error;
|
||||
|
||||
PREPARE_ERROR(errctx);
|
||||
error_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
akerr_handler_unhandled_error = handle_unhandled_error_noexit;
|
||||
ATTEMPT {
|
||||
UNHANDLED_ERROR_BEHAVIOR = UNHANDLED_ERROR_SET;
|
||||
CATCH(unhandled_error_context, heap_next_actor(&testactor));
|
||||
@@ -131,13 +129,13 @@ ErrorContext *test_registry_actor_iterator_updaterender(void)
|
||||
FAIL_ZERO_BREAK(
|
||||
unhandled_error_context,
|
||||
actor_updated,
|
||||
ERR_BEHAVIOR,
|
||||
AKERR_BEHAVIOR,
|
||||
"actor->updatefunc not called by the iterator"
|
||||
);
|
||||
FAIL_ZERO_BREAK(
|
||||
unhandled_error_context,
|
||||
actor_rendered,
|
||||
ERR_BEHAVIOR,
|
||||
AKERR_BEHAVIOR,
|
||||
"actor->renderfunc not called by the iterator"
|
||||
);
|
||||
} CLEANUP {
|
||||
@@ -146,13 +144,12 @@ ErrorContext *test_registry_actor_iterator_updaterender(void)
|
||||
} PROCESS(unhandled_error_context) {
|
||||
} FINISH(unhandled_error_context, true);
|
||||
|
||||
IGNORE(heap_release_error(unhandled_error_context));
|
||||
error_handler_unhandled_error = defaulthandler;
|
||||
akerr_handler_unhandled_error = defaulthandler;
|
||||
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_actor_set_character(void)
|
||||
akerr_ErrorContext *test_actor_set_character(void)
|
||||
{
|
||||
actor *testactor = NULL;
|
||||
character *testchar = NULL;
|
||||
@@ -163,7 +160,7 @@ ErrorContext *test_actor_set_character(void)
|
||||
CATCH(errctx, actor_set_character(NULL, "test"));
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
printf("Handled\n");
|
||||
} FINISH(errctx, true);
|
||||
|
||||
@@ -180,7 +177,7 @@ ErrorContext *test_actor_set_character(void)
|
||||
} CLEANUP {
|
||||
IGNORE(heap_release_actor(testactor));
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_NULLPOINTER) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
printf("Handled\n");
|
||||
} FINISH(errctx, true);
|
||||
|
||||
@@ -205,7 +202,7 @@ ErrorContext *test_actor_set_character(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
ErrorContext *test_actor_manage_children(void)
|
||||
akerr_ErrorContext *test_actor_manage_children(void)
|
||||
{
|
||||
actor *parent = NULL;
|
||||
actor *child = NULL;
|
||||
@@ -238,12 +235,12 @@ ErrorContext *test_actor_manage_children(void)
|
||||
CATCH(errctx, parent->addchild(parent, child));
|
||||
} CLEANUP {
|
||||
if ( errctx == NULL ) {
|
||||
FAIL(errctx, ERR_BEHAVIOR, "addchild does not throw ERR_RELATIONSHIP when child already has a parent");
|
||||
FAIL(errctx, AKERR_BEHAVIOR, "addchild does not throw AKERR_RELATIONSHIP when child already has a parent");
|
||||
}
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_RELATIONSHIP) {
|
||||
} HANDLE(errctx, AKERR_RELATIONSHIP) {
|
||||
// Expected behavior
|
||||
SDL_Log("addchild throws ERR_RELATIONSHIP when child already has a parent");
|
||||
SDL_Log("addchild throws AKERR_RELATIONSHIP when child already has a parent");
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
@@ -251,23 +248,23 @@ ErrorContext *test_actor_manage_children(void)
|
||||
CATCH(errctx, parent->addchild(parent, child));
|
||||
} CLEANUP {
|
||||
if ( errctx == NULL ) {
|
||||
FAIL(errctx, ERR_BEHAVIOR, "addchild does not throw ERR_OUTOFBOUNDS when all children already set");
|
||||
FAIL(errctx, AKERR_BEHAVIOR, "addchild does not throw AKERR_OUTOFBOUNDS when all children already set");
|
||||
}
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, ERR_OUTOFBOUNDS) {
|
||||
} HANDLE(errctx, AKERR_OUTOFBOUNDS) {
|
||||
// Expected behavior
|
||||
SDL_Log("addchild throws ERR_OUTOFBOUNDS when all children already set");
|
||||
SDL_Log("addchild throws AKERR_OUTOFBOUNDS when all children already set");
|
||||
} FINISH(errctx, true);
|
||||
|
||||
ATTEMPT {
|
||||
CATCH(errctx, heap_release_actor(parent));
|
||||
// All actor objects on the heap should be empty now
|
||||
for ( i = 0; i < MAX_HEAP_ACTOR; i++) {
|
||||
FAIL_NONZERO_BREAK(errctx, HEAP_ACTOR[i].refcount, ERR_VALUE, "Actor not properly cleared");
|
||||
FAIL_NONZERO_BREAK(errctx, HEAP_ACTOR[i].parent, ERR_VALUE, "Actor not properly cleared");
|
||||
FAIL_NONZERO_BREAK(errctx, HEAP_ACTOR[i].refcount, AKERR_VALUE, "Actor not properly cleared");
|
||||
FAIL_NONZERO_BREAK(errctx, HEAP_ACTOR[i].parent, AKERR_VALUE, "Actor not properly cleared");
|
||||
for ( j = 0 ; j < ACTOR_MAX_CHILDREN; j++) {
|
||||
if ( HEAP_ACTOR[i].children[j] != NULL ) {
|
||||
FAIL(errctx, ERR_VALUE, "Actor not properly cleared");
|
||||
FAIL(errctx, AKERR_VALUE, "Actor not properly cleared");
|
||||
goto _test_actor_addchild_heaprelease_cleanup;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +274,7 @@ ErrorContext *test_actor_manage_children(void)
|
||||
FAIL_NONZERO_BREAK(
|
||||
errctx,
|
||||
SDL_GetPointerProperty(REGISTRY_ACTOR, (char *)&tmpstring->data, NULL),
|
||||
ERR_KEY,
|
||||
AKERR_KEY,
|
||||
"Child %s was not removed from the registry",
|
||||
(char *)&tmpstring->data);
|
||||
}
|
||||
@@ -293,13 +290,13 @@ _test_actor_addchild_heaprelease_cleanup:
|
||||
CATCH(errctx, actor_initialize(child, "child"));
|
||||
// Don't release our claim on the child. The child should not be reclaimed.
|
||||
CATCH(errctx, heap_release_actor(parent));
|
||||
FAIL_NONZERO_BREAK(errctx, child->parent, ERR_VALUE, "Child still references released parent");
|
||||
FAIL_ZERO_BREAK(errctx, child->refcount, ERR_VALUE, "Child prematurely released");
|
||||
FAIL_NONZERO_BREAK(errctx, strcmp(child->name, "child"), ERR_VALUE, "Child had identity erased");
|
||||
FAIL_NONZERO_BREAK(errctx, child->parent, AKERR_VALUE, "Child still references released parent");
|
||||
FAIL_ZERO_BREAK(errctx, child->refcount, AKERR_VALUE, "Child prematurely released");
|
||||
FAIL_NONZERO_BREAK(errctx, strcmp(child->name, "child"), AKERR_VALUE, "Child had identity erased");
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
(child == SDL_GetPointerProperty(REGISTRY_ACTOR, child->name, NULL)),
|
||||
ERR_KEY,
|
||||
AKERR_KEY,
|
||||
"Child prematurely removed from the registry");
|
||||
// Now we can release the child
|
||||
CATCH(errctx, heap_release_actor(child));
|
||||
|
||||
Reference in New Issue
Block a user