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 /strcaseends.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 'strcaseends.c')
-rw-r--r-- | strcaseends.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/strcaseends.c b/strcaseends.c index a672b0a..6ff9d8b 100644 --- a/strcaseends.c +++ b/strcaseends.c @@ -11,3 +11,43 @@ libsimple_strcaseends(const char *s, const char *t) return 0; return !strcasecmp(&s[sn - tn], t); } + + +#ifdef TEST +#include <assert.h> + +int +main(void) +{ + assert(libsimple_strcaseends("", "") == 1); + assert(libsimple_strcaseends("test", "") == 1); + assert(libsimple_strcaseends("", "test") == 0); + assert(libsimple_strcaseends("test", "test") == 1); + assert(libsimple_strcaseends("test", "testx") == 0); + assert(libsimple_strcaseends("test", "est") == 1); + assert(libsimple_strcaseends("test", "st") == 1); + assert(libsimple_strcaseends("test", "t") == 1); + assert(libsimple_strcaseends("test", "x") == 0); + assert(libsimple_strcaseends("test", "xx") == 0); + + assert(libsimple_strcaseends("TEST", "") == 1); + assert(libsimple_strcaseends("TEST", "test") == 1); + assert(libsimple_strcaseends("TEST", "testx") == 0); + assert(libsimple_strcaseends("TEST", "est") == 1); + assert(libsimple_strcaseends("TEST", "st") == 1); + assert(libsimple_strcaseends("TEST", "t") == 1); + assert(libsimple_strcaseends("TEST", "x") == 0); + assert(libsimple_strcaseends("TEST", "xx") == 0); + + assert(libsimple_strcaseends("", "TEST") == 0); + assert(libsimple_strcaseends("test", "TEST") == 1); + assert(libsimple_strcaseends("test", "TESTX") == 0); + assert(libsimple_strcaseends("test", "EST") == 1); + assert(libsimple_strcaseends("test", "ST") == 1); + assert(libsimple_strcaseends("test", "T") == 1); + assert(libsimple_strcaseends("test", "X") == 0); + assert(libsimple_strcaseends("test", "XX") == 0); + return 0; +} + +#endif |