From 26c490f404731d053a6205719b6246502c07b449 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 14 Jun 2014 16:46:27 +0200 Subject: init --- ccc/stringutil_test.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ccc/stringutil_test.c (limited to 'ccc/stringutil_test.c') diff --git a/ccc/stringutil_test.c b/ccc/stringutil_test.c new file mode 100644 index 0000000..798bccd --- /dev/null +++ b/ccc/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; +} + -- cgit v1.2.3