Unify the library on an akgl_ namespace
This commit is contained in:
@@ -7,12 +7,12 @@ void reset_string_heap(void);
|
||||
|
||||
akerr_ErrorContext *test_fresh_heap_gives_strings(void)
|
||||
{
|
||||
string *ptr = NULL;
|
||||
akgl_String *ptr = NULL;
|
||||
|
||||
PREPARE_ERROR(errctx);
|
||||
for ( int i = 0; i < MAX_HEAP_STRING - 1; i++ ) {
|
||||
for ( int i = 0; i < AKGL_MAX_HEAP_STRING - 1; i++ ) {
|
||||
ATTEMPT {
|
||||
CATCH(errctx, heap_next_string(&ptr));
|
||||
CATCH(errctx, akgl_heap_next_string(&ptr));
|
||||
} CLEANUP {
|
||||
reset_string_heap();
|
||||
} PROCESS(errctx) {
|
||||
@@ -24,14 +24,14 @@ akerr_ErrorContext *test_fresh_heap_gives_strings(void)
|
||||
|
||||
akerr_ErrorContext *test_string_heap_error_when_no_strings_left(void)
|
||||
{
|
||||
string *ptr;
|
||||
akgl_String *ptr;
|
||||
PREPARE_ERROR(errctx);
|
||||
for ( int i = 0; i < MAX_HEAP_STRING; i++ ) {
|
||||
for ( int i = 0; i < AKGL_MAX_HEAP_STRING; i++ ) {
|
||||
HEAP_STRING[i].refcount = 1;
|
||||
}
|
||||
for ( int i = 0; i < MAX_HEAP_STRING - 1; i++ ) {
|
||||
for ( int i = 0; i < AKGL_MAX_HEAP_STRING - 1; i++ ) {
|
||||
ATTEMPT {
|
||||
CATCH(errctx, heap_next_string(&ptr));
|
||||
CATCH(errctx, akgl_heap_next_string(&ptr));
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
||||
@@ -44,12 +44,12 @@ akerr_ErrorContext *test_string_heap_error_when_no_strings_left(void)
|
||||
|
||||
akerr_ErrorContext *test_string_heap_honors_refcount(void)
|
||||
{
|
||||
string *firstptr = &HEAP_STRING[0];
|
||||
string *secondptr = &HEAP_STRING[1];
|
||||
string *testptr = NULL;
|
||||
akgl_String *firstptr = &HEAP_STRING[0];
|
||||
akgl_String *secondptr = &HEAP_STRING[1];
|
||||
akgl_String *testptr = NULL;
|
||||
PREPARE_ERROR(errctx);
|
||||
ATTEMPT {
|
||||
CATCH(errctx, heap_next_string(&testptr));
|
||||
CATCH(errctx, akgl_heap_next_string(&testptr));
|
||||
if ( testptr != firstptr ) {
|
||||
FAIL_RETURN(
|
||||
errctx,
|
||||
@@ -59,7 +59,7 @@ akerr_ErrorContext *test_string_heap_honors_refcount(void)
|
||||
testptr
|
||||
);
|
||||
}
|
||||
CATCH(errctx, string_initialize(testptr, NULL));
|
||||
CATCH(errctx, akgl_string_initialize(testptr, NULL));
|
||||
if ( testptr->refcount == 0 ) {
|
||||
FAIL_RETURN(errctx, AKERR_VALUE, "Expected string reference count to be nonzero but got 0");
|
||||
}
|
||||
@@ -72,7 +72,7 @@ akerr_ErrorContext *test_string_heap_honors_refcount(void)
|
||||
testptr
|
||||
);
|
||||
}
|
||||
CATCH(errctx, heap_next_string(&testptr));
|
||||
CATCH(errctx, akgl_heap_next_string(&testptr));
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} FINISH(errctx, true);
|
||||
@@ -81,14 +81,14 @@ akerr_ErrorContext *test_string_heap_honors_refcount(void)
|
||||
|
||||
akerr_ErrorContext *test_strcpy_to_all_strings_no_segfault(void)
|
||||
{
|
||||
char copybuf[MAX_STRING_LENGTH];
|
||||
string *ptr;
|
||||
memset((void *)©buf, 'a', MAX_STRING_LENGTH);
|
||||
char copybuf[AKGL_MAX_STRING_LENGTH];
|
||||
akgl_String *ptr;
|
||||
memset((void *)©buf, 'a', AKGL_MAX_STRING_LENGTH);
|
||||
PREPARE_ERROR(errctx);
|
||||
ATTEMPT {
|
||||
for ( int i = 0; i < MAX_HEAP_STRING - 1; i++ ) {
|
||||
CATCH(errctx, heap_next_string(&ptr));
|
||||
strncpy(ptr->data, (char *)©buf, MAX_STRING_LENGTH);
|
||||
for ( int i = 0; i < AKGL_MAX_HEAP_STRING - 1; i++ ) {
|
||||
CATCH(errctx, akgl_heap_next_string(&ptr));
|
||||
strncpy(ptr->data, (char *)©buf, AKGL_MAX_STRING_LENGTH);
|
||||
}
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
@@ -96,21 +96,21 @@ akerr_ErrorContext *test_strcpy_to_all_strings_no_segfault(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *test_string_initialize(void)
|
||||
akerr_ErrorContext *test_akgl_string_initialize(void)
|
||||
{
|
||||
string *ptr;
|
||||
akgl_String *ptr;
|
||||
PREPARE_ERROR(errctx);
|
||||
ATTEMPT {
|
||||
CATCH(errctx, heap_next_string(&ptr));
|
||||
CATCH(errctx, string_initialize(ptr, NULL));
|
||||
CATCH(errctx, akgl_heap_next_string(&ptr));
|
||||
CATCH(errctx, akgl_string_initialize(ptr, NULL));
|
||||
FAIL_NONZERO_BREAK(errctx, ptr->data[0], AKERR_VALUE, "Expected empty zero length string data");
|
||||
|
||||
CATCH(errctx, heap_release_string(ptr));
|
||||
CATCH(errctx, heap_next_string(&ptr));
|
||||
CATCH(errctx, string_initialize(ptr, "Test value"));
|
||||
CATCH(errctx, akgl_heap_release_string(ptr));
|
||||
CATCH(errctx, akgl_heap_next_string(&ptr));
|
||||
CATCH(errctx, akgl_string_initialize(ptr, "Test value"));
|
||||
FAIL_NONZERO_BREAK(errctx, strcmp((char *)&ptr->data, "Test value"), AKERR_VALUE, "Expected 'Test value', got %s", (char *)&ptr->data);
|
||||
|
||||
CATCH(errctx, heap_release_string(NULL));
|
||||
CATCH(errctx, akgl_heap_release_string(NULL));
|
||||
FAIL_BREAK(errctx, AKERR_BEHAVIOR, "Failure to properly handle NULL pointer");
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
@@ -122,8 +122,8 @@ akerr_ErrorContext *test_string_initialize(void)
|
||||
|
||||
void reset_string_heap(void)
|
||||
{
|
||||
for ( int i = 0; i < MAX_HEAP_STRING; i++ ) {
|
||||
memset(&HEAP_STRING[i], 0x00, sizeof(string));
|
||||
for ( int i = 0; i < AKGL_MAX_HEAP_STRING; i++ ) {
|
||||
memset(&HEAP_STRING[i], 0x00, sizeof(akgl_String));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ int main(void)
|
||||
printf("test_strcpy_to_all_strings_no_segfault ...\n");
|
||||
test_strcpy_to_all_strings_no_segfault();
|
||||
reset_string_heap();
|
||||
printf("test_string_initialize....\n");
|
||||
test_string_initialize();
|
||||
printf("test_akgl_string_initialize....\n");
|
||||
test_akgl_string_initialize();
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} FINISH_NORETURN(errctx);
|
||||
|
||||
Reference in New Issue
Block a user