use assert instead of ambiuous return code
This commit is contained in:
22
test/array.c
22
test/array.c
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user