use calloc() instead of malloc()
[cvector.git] / test / test2.c
blobdb5e70567517d9244124aeb04811218fd9d2ea4a
1 #include "vectors.h"
3 #include <stdio.h>
5 #define SIZE 10
7 uint32_t uTable[SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
9 bool equal(uint32_t u1, uint32_t u2) { return (u1 == u2); }
11 int main() {
12 u32vec uvec = u32vec_create(0);
13 u32vec_print(uvec, "%u", NULL);
14 printf(" size:%zu \n", uvec.capacity);
16 u32vec_push_array(&uvec, uTable, SIZE);
17 u32vec_print(uvec, "%u", NULL);
18 printf(" size:%zu \n", uvec.capacity);
20 u32vec uvec2 = u32vec_create(0);
21 u32vec_print(uvec2, "%u", NULL);
22 printf(" size:%zu \n", uvec2.capacity);
24 u32vec_push_array(&uvec2, uTable, SIZE);
25 u32vec_print(uvec2, "%u", NULL);
26 printf(" size:%zu \n", uvec2.capacity);
28 if (u32vec_eqv(uvec, uvec2, equal)) {
29 printf("SAME\n");
30 } else {
31 printf("NOT THE SAME\n");
34 u32vec_insert_array(&uvec, 1,uTable, SIZE);
35 /*u32vec_print(uvec, "%u", NULL);
36 printf(" size:%u \n", uvec.memorySize);*/
38 /*u32vec_insertvec(&uvec, 1, uvec2);
39 u32vec_print(uvec, "%u", NULL);
40 printf(" size:%u \n", uvec.memorySize);*/
43 if (u32vec_eqv(uvec, uvec2, equal)) {
44 printf("SAME\n");
45 } else {
46 printf("NOT THE SAME\n");
49 u32vec_free(&uvec);
50 u32vec_free(&uvec2);