-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathvector-test.c
50 lines (39 loc) · 1.2 KB
/
vector-test.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include "vector.h"
int main(int argc, char **argv) {
vector_t *v;
printf("Calling vector_new()\n");
v = vector_new();
printf("Calling vector_delete()\n");
vector_delete(v);
printf("vector_new() again\n");
v = vector_new();
printf("These should all return 0 (vector_get()): ");
printf("%d ", vector_get(v, 0));
printf("%d ", vector_get(v, 1));
printf("%d\n", vector_get(v, 2));
printf("Doing a bunch of vector_set()s\n");
vector_set(v, 0, 98);
vector_set(v, 11, 15);
vector_set(v, 15, -23);
vector_set(v, 24, 65);
vector_set(v, 500, 3);
vector_set(v, 12, -123);
vector_set(v, 15, 21);
vector_set(v, 25, 43);
printf("These should be equal:\n");
printf("98 = %d\n", vector_get(v, 0));
printf("15 = %d\n", vector_get(v, 11));
printf("65 = %d\n", vector_get(v, 24));
printf("-123 = %d\n", vector_get(v, 12));
printf("21 = %d\n", vector_get(v, 15));
printf("43 = %d\n", vector_get(v, 25));
printf("0 = %d\n", vector_get(v, 23));
printf("0 = %d\n", vector_get(v, 1));
printf("0 = %d\n", vector_get(v, 501));
printf("3 = %d\n", vector_get(v, 500));
vector_delete(v);
printf("Test complete.\n");
return 0;
}