summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix von Leitner <felix-libowfat@fefe.de>2018-09-30 19:29:31 +0000
committerFelix von Leitner <felix-libowfat@fefe.de>2018-09-30 19:29:31 +0000
commiteb4d3afbea0662a8d9e0d4b3cafcb5d3480d0789 (patch)
treef58349e5afba9e1520c04f711e203ee5901583cf
parent2c4e279f1efe411bcd9e7deb3b2194db2e902b87 (diff)
downloadlibowfat-eb4d3afbea0662a8d9e0d4b3cafcb5d3480d0789.tar.gz
libowfat-eb4d3afbea0662a8d9e0d4b3cafcb5d3480d0789.zip
add unit test
-rw-r--r--str/str_chr.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/str/str_chr.c b/str/str_chr.c
index 37d24fe..418dd57 100644
--- a/str/str_chr.c
+++ b/str/str_chr.c
@@ -15,3 +15,17 @@ size_t str_chr(const char *in, char needle) {
}
return (size_t)(t-in);
}
+
+#ifdef UNITTEST
+#include <assert.h>
+#include <string.h>
+
+int main() {
+ char buf[100];
+ strcpy(buf,"abcdefghijklmnopqrstuvwxyz");
+ size_t i;
+ for (i=0; i<26; ++i)
+ assert(str_chr(buf,buf[i])==i);
+ assert(str_chr(buf,'X')==26);
+}
+#endif