diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-12 21:35:12 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-12 21:35:12 +0200 |
commit | 93b8428b5812191177c790ea9ffb9158d5a296b4 (patch) | |
tree | 8e43220208a7e3b4780a49b8278e731f3b5fcbbf /strcasestr.c | |
parent | Add DONT_DEFINE_CLOCK_MONOTONIC_RAW (diff) | |
download | libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.gz libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.bz2 libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.xz |
Add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'strcasestr.c')
-rw-r--r-- | strcasestr.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/strcasestr.c b/strcasestr.c index 62bcfdb..a3a98fc 100644 --- a/strcasestr.c +++ b/strcasestr.c @@ -15,3 +15,61 @@ libsimple_strcasestr(const char *h_, const char *n) return h; return NULL; } + + +#ifdef TEST +#include <assert.h> + +int +main(void) +{ + assert(!strcmp(libsimple_strcasestr("", ""), "")); + assert(!strcmp(libsimple_strcasestr("test", ""), "test")); + assert(!libsimple_strcasestr("", "test")); + assert(!libsimple_strcasestr("t", "test")); + assert(!strcmp(libsimple_strcasestr("test", "t"), "test")); + assert(!strcmp(libsimple_strcasestr("test", "e"), "est")); + assert(!strcmp(libsimple_strcasestr("test", "s"), "st")); + assert(!libsimple_strcasestr("test", "x")); + assert(!strcmp(libsimple_strcasestr("test", "te"), "test")); + assert(!strcmp(libsimple_strcasestr("test", "es"), "est")); + assert(!strcmp(libsimple_strcasestr("test", "st"), "st")); + assert(!libsimple_strcasestr("test", "xx")); + assert(!strcmp(libsimple_strcasestr("abc", "c"), "c")); + assert(!strcmp(libsimple_strcasestr("abc", "bc"), "bc")); + assert(!strcmp(libsimple_strcasestr("abc", "abc"), "abc")); + assert(!strcmp(libsimple_strcasestr("abcabc", "bc"), "bcabc")); + + assert(!strcmp(libsimple_strcasestr("TEST", ""), "TEST")); + assert(!libsimple_strcasestr("T", "test")); + assert(!strcmp(libsimple_strcasestr("TEST", "t"), "TEST")); + assert(!strcmp(libsimple_strcasestr("TEST", "e"), "EST")); + assert(!strcmp(libsimple_strcasestr("TEST", "s"), "ST")); + assert(!libsimple_strcasestr("TEST", "x")); + assert(!strcmp(libsimple_strcasestr("TEST", "te"), "TEST")); + assert(!strcmp(libsimple_strcasestr("TEST", "es"), "EST")); + assert(!strcmp(libsimple_strcasestr("TEST", "st"), "ST")); + assert(!libsimple_strcasestr("TEST", "xx")); + assert(!strcmp(libsimple_strcasestr("ABC", "c"), "C")); + assert(!strcmp(libsimple_strcasestr("ABC", "bc"), "BC")); + assert(!strcmp(libsimple_strcasestr("ABC", "abc"), "ABC")); + assert(!strcmp(libsimple_strcasestr("ABCABC", "bc"), "BCABC")); + + assert(!libsimple_strcasestr("", "TEST")); + assert(!libsimple_strcasestr("t", "TEST")); + assert(!strcmp(libsimple_strcasestr("test", "T"), "test")); + assert(!strcmp(libsimple_strcasestr("test", "E"), "est")); + assert(!strcmp(libsimple_strcasestr("test", "S"), "st")); + assert(!libsimple_strcasestr("test", "X")); + assert(!strcmp(libsimple_strcasestr("test", "TE"), "test")); + assert(!strcmp(libsimple_strcasestr("test", "ES"), "est")); + assert(!strcmp(libsimple_strcasestr("test", "ST"), "st")); + assert(!libsimple_strcasestr("test", "XX")); + assert(!strcmp(libsimple_strcasestr("abc", "C"), "c")); + assert(!strcmp(libsimple_strcasestr("abc", "BC"), "bc")); + assert(!strcmp(libsimple_strcasestr("abc", "ABC"), "abc")); + assert(!strcmp(libsimple_strcasestr("abcabc", "BC"), "bcabc")); + return 0; +} + +#endif |