modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / lib / cstring / test.c
blobec1cfbb7351a3a060a68ffefc3c5a31fdb33a07d
1 #include "cstring.h"
3 #include <stdio.h>
5 static cstring
6 foo(cstring t) {
7 CSTRING_LITERAL(hello, "hello");
8 CSTRING_BUFFER(ret);
9 if (cstring_equal(hello,t)) {
10 cstring_cat(ret, "equal");
11 } else {
12 cstring_cat(ret, "not equal");
14 return cstring_grab(CSTRING(ret));
17 static void
18 test() {
19 CSTRING_BUFFER(a);
20 cstring_printf(a, "%s", "hello");
21 cstring b = foo(CSTRING(a));
22 printf("%s\n", b->cstr);
23 cstring_printf(a, "very long string %01024d",0);
24 printf("%s\n", CSTRING(a)->cstr);
25 CSTRING_CLOSE(a);
26 cstring_release(b);
29 int
30 main() {
31 test();
32 return 0;