27 lines
650 B
C
27 lines
650 B
C
|
|
#define L_ARRAY_IMPLEMENTATION
|
||
|
|
#include "../include/array.h"
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
int test_l_array() {
|
||
|
|
int RETURN_CODE = 0;
|
||
|
|
printf("test_l_array() : ");
|
||
|
|
|
||
|
|
LArray* array = l_array_create();
|
||
|
|
|
||
|
|
int number_1 = 5;
|
||
|
|
int number_2 = 15;
|
||
|
|
|
||
|
|
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++;
|
||
|
|
|
||
|
|
l_array_clear(array);
|
||
|
|
if (array->items != NULL) RETURN_CODE++;
|
||
|
|
|
||
|
|
printf("%d\n", RETURN_CODE);
|
||
|
|
return RETURN_CODE;
|
||
|
|
}
|