Files
ltypes/test/array.c

28 lines
637 B
C
Raw Normal View History

2026-06-10 09:06:08 -05:00
#define L_ARRAY_IMPLEMENTATION
2026-06-14 07:41:14 -05:00
#include "../include/larray.h"
#include <assert.h>
2026-06-10 09:06:08 -05:00
int 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);
assert(*(int*)array->items[0] == 15);
assert(*(int*)array->items[1] == 5);
assert(array->count == 2);
assert(array->capacity == 8);
2026-06-10 09:06:08 -05:00
2026-06-14 07:41:14 -05:00
l_array_swap(array, 0, 1);
assert(*(int*)array->items[0] == 5);
assert(*(int*)array->items[1] == 15);
2026-06-14 07:41:14 -05:00
2026-06-10 09:06:08 -05:00
l_array_clear(array);
assert(array->items == NULL);
2026-06-10 09:06:08 -05:00
2026-07-10 04:17:51 -05:00
l_array_delete(array);
return 0;
2026-06-10 09:06:08 -05:00
}