-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_vec.c
More file actions
36 lines (26 loc) · 693 Bytes
/
Copy pathtest_vec.c
File metadata and controls
36 lines (26 loc) · 693 Bytes
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
32
33
34
35
36
#include "vec.h"
#include "std.h"
void test_vec(void) {
Vec *v;
int i;
v = vec_new();
assert(v->size == 0);
vec_push(v, (void *)(intptr_t)1);
vec_push(v, (void *)(intptr_t)2);
assert(v->size == 2);
assert((intptr_t)v->data[0] == 1);
assert((intptr_t)v->data[1] == 2);
assert((intptr_t)vec_back(v) == 2);
for (i = 0; i < 100; i++) {
vec_push(v, (void *)(intptr_t)i);
}
assert(v->size == 102);
assert((intptr_t)vec_back(v) == 99);
for (i = 0; i < 100; i++) {
vec_pop(v);
}
assert(v->size == 2);
assert((intptr_t)vec_pop(v) == 2);
assert((intptr_t)vec_pop(v) == 1);
assert(v->size == 0);
}