diff options
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 |