summaryrefslogtreecommitdiff
path: root/test/test_vec.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_vec.c')
-rw-r--r--test/test_vec.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_vec.c b/test/test_vec.c
new file mode 100644
index 0000000..a9788eb
--- /dev/null
+++ b/test/test_vec.c
@@ -0,0 +1,31 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "util/alloc.h"
+#include "util/vec.h"
+
+int main(int argc, char **argv) {
+
+ struct LEO_Allocator allocator = {
+ malloc,
+ realloc,
+ free,
+ NULL
+ };
+
+ struct LEO_Vec vec;
+ assert(LEO_Vec_init(&vec, sizeof(int), allocator) == LEO_Vec_OK);
+
+ for (int i = 0; i < 100; i++) {
+ assert(LEO_Vec_push(&vec, &i) == LEO_Vec_OK);
+ }
+
+ for (int i = 0; i < 100; i++) {
+ int item;
+ assert(LEO_Vec_get(&vec, i, &item) == LEO_Vec_OK);
+ assert(item == i);
+ }
+
+ LEO_Vec_free(&vec);
+ return 0;
+}