diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-15 03:50:12 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-15 03:50:12 +0200 |
commit | 258e1b92ebbfdebefabc120969ab87c3d8b75c3d (patch) | |
tree | ef4ab11fe0bf9d720cea23b35711358a8465feeb /c,cc/stringutil_test.c | |
parent | cf3a29feb5887344b6633ead1b4b6d5657a15a4b (diff) |
old c,cc examples
Diffstat (limited to 'c,cc/stringutil_test.c')
-rw-r--r-- | c,cc/stringutil_test.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/c,cc/stringutil_test.c b/c,cc/stringutil_test.c new file mode 100644 index 0000000..798bccd --- /dev/null +++ b/c,cc/stringutil_test.c @@ -0,0 +1,53 @@ +#include "filelib.h" +#include "stringutil.h" + + +int +main(void) +{ + /* + * strend + * + */ + char* s= ""; + char* end = strend(s); + if (end) + printf("should not output: %s\n", end); + + s = "asdf.gz"; + end = strend(s); + if (end) + printf("expect 'z': %s\n", end); + + /* + * endswith + * + */ + if (endswith(s, ".gz")) + printf("%s ends with %s\n", s, ".gz"); + + if (endswith(".gz", ".gz")) + printf(".gz ends with .gz\n"); + + if(!endswith("gz", ".gz")) + printf("gz does not end with .gz\n"); + + /* + * filelib + * + */ + hFile* f = makef("-", "a"); + if (!f) + printf("Error creating file '%s'\n", "-"); + writeln("this goes to stdout", f); + closef(f); + + hFile* g = makef("gzfile.gz", "a"); + if (!g) + printf("Error creating file '%s'\n", "-"); + writeln("this should be compressed", g); + closef(g); + + return 0; +} + |