aboutsummaryrefslogtreecommitdiffstats
path: root/strrchr_inv.c
diff options
context:
space:
mode:
Diffstat (limited to 'strrchr_inv.c')
-rw-r--r--strrchr_inv.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/strrchr_inv.c b/strrchr_inv.c
index 2b57fdf..3fdd1dc 100644
--- a/strrchr_inv.c
+++ b/strrchr_inv.c
@@ -4,7 +4,7 @@
char *
-libsimple_strrchr_inv(const char *s_, int c_) /* TODO test, man */
+libsimple_strrchr_inv(const char *s_, int c_) /* TODO man */
{
char *s = *(char **)(void *)&s_, c = (char)c_, *r = NULL;
for (; *s; s++)
@@ -20,6 +20,13 @@ libsimple_strrchr_inv(const char *s_, int c_) /* TODO test, man */
int
main(void)
{
+ assert(!strcmpnul(libsimple_strrchr_inv("aabbaabb", 'b'), "abb"));
+ assert(!strcmpnul(libsimple_strrchr_inv("aabbaabb", 'B'), "b"));
+ assert(!strcmpnul(libsimple_strrchr_inv("AABBAABB", 'b'), "B"));
+ assert(!strcmpnul(libsimple_strrchr_inv("AABBAABB", 'B'), "ABB"));
+ assert(!strcmpnul(libsimple_strrchr_inv("aabbaabb", 'a'), "b"));
+ assert(!strcmpnul(libsimple_strrchr_inv("aabbaabb", '\0'), "b"));
+ assert(!strcmpnul(libsimple_strrchr_inv("--------", '-'), NULL));
return 0;
}