add dynamic array
This commit is contained in:
41
test.c
Normal file
41
test.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#define L_ARRAY_IMPLEMENTATION
|
||||
#include "array.h"
|
||||
#include "assert.h"
|
||||
|
||||
#define TEST_FUNCTION
|
||||
|
||||
static int test_l_array() {
|
||||
int RETURN_CODE = 0;
|
||||
|
||||
l_array* array = l_array_create();
|
||||
|
||||
int number_1 = 5;
|
||||
int number_2 = 15;
|
||||
|
||||
l_array_append(array, &number_2);
|
||||
l_array_append(array, &number_1);
|
||||
|
||||
assert(*(int*)array->items[0] == 15);
|
||||
assert(*(int*)array->items[1] == 5);
|
||||
assert(array->count == 2);
|
||||
assert(array->capacity == 8);
|
||||
|
||||
l_array_clear(array);
|
||||
assert(array->items == NULL);
|
||||
|
||||
return RETURN_CODE;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("AUTHOR: %s\n", L_TYPES_AUTHOR);
|
||||
printf("REPO: %s\n", L_TYPES_REPO);
|
||||
printf("VERSION: %s\n", L_TYPES_VERSION);
|
||||
printf("LICENSE: %s\n\n", L_TYPES_LICENSE);
|
||||
|
||||
|
||||
if (
|
||||
test_l_array()
|
||||
) return 1;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user