modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / lib / uthash / libut / tests / test15.c
blob62bfd3c930b8c77c210fbdcfb76d5de2728dc930
1 #include <stdio.h>
2 #include "libut.h"
4 void dump(UT_vector *v) {
5 printf("len: %d\n", utvector_len(v));
6 UT_string *p=NULL;
7 while ( (p=(UT_string*)utvector_next(v,p))) printf("%s\n",utstring_body(p));
10 int main() {
11 int i;
12 UT_string *t;
13 UT_vector v; utvector_init(&v, utstring_mm);
14 UT_string s; utstring_init(&s);
16 for(i=0; i<16; i++) {
17 utstring_printf(&s, ".");
18 utvector_push(&v, &s);
20 dump(&v);
22 t = (UT_string*)utvector_head(&v);
23 printf("head: %s %s\n", t?"non-null":"null", t?utstring_body(t):"-");
25 t = (UT_string*)utvector_tail(&v);
26 printf("tail: %s %s\n", t?"non-null":"null", t?utstring_body(t):"-");
28 for(i=0; i<16; i++) {
29 printf("shift\n");
30 utvector_shift(&v);
31 t = (UT_string*)utvector_head(&v);
32 printf("len: %d, head: %s %s\n", utvector_len(&v), t?"non-null":"null", t?utstring_body(t):"-");
35 printf("extend\n");
36 t= (UT_string*)utvector_extend(&v);
37 utstring_printf(t,"extended");
38 t = (UT_string*)utvector_head(&v);
39 printf("len: %d, head: %s %s\n", utvector_len(&v), t?"non-null":"null", t?utstring_body(t):"-");
41 utvector_fini(&v);
42 utstring_done(&s);
43 return 0;