blob: a9788eb4d7710a57ba8e4e916adfe85281039034 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}
|