use assert instead of ambiuous return code

This commit is contained in:
2026-07-12 18:09:46 -05:00
parent 96e1a8e0d6
commit baa683d970
3 changed files with 18 additions and 28 deletions

View File

@@ -1,11 +1,8 @@
#define L_ARRAY_IMPLEMENTATION
#include "../include/larray.h"
#include <stdio.h>
#include <assert.h>
int test_l_array() {
int RETURN_CODE = 0;
printf("test_l_array() : ");
LArray* array = l_array_create();
int number_1 = 5;
@@ -14,19 +11,18 @@ int test_l_array() {
l_array_append(array, &number_2);
l_array_append(array, &number_1);
if (*(int*)array->items[0] != 15) RETURN_CODE++;
if (*(int*)array->items[1] != 5) RETURN_CODE++;
if (array->count != 2) RETURN_CODE++;
if (array->capacity != 8) RETURN_CODE++;
assert(*(int*)array->items[0] == 15);
assert(*(int*)array->items[1] == 5);
assert(array->count == 2);
assert(array->capacity == 8);
l_array_swap(array, 0, 1);
if (*(int*)array->items[0] != 5) RETURN_CODE++;
if (*(int*)array->items[1] != 15) RETURN_CODE++;
assert(*(int*)array->items[0] == 5);
assert(*(int*)array->items[1] == 15);
l_array_clear(array);
if (array->items != NULL) RETURN_CODE++;
assert(array->items == NULL);
printf("%d\n", RETURN_CODE);
l_array_delete(array);
return RETURN_CODE;
return 0;
}