diff options
author | Mattias Andrée <maandree@kth.se> | 2018-11-23 20:38:54 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-11-23 20:38:54 +0100 |
commit | b5ca6729c7b52e8cade6d3808ad8280845ac32ea (patch) | |
tree | 0ddac006e8a6bad962c7c981449ba43fb4bc195f /strrchr_inv.c | |
parent | Add a bunch of function and macros (diff) | |
download | libsimple-b5ca6729c7b52e8cade6d3808ad8280845ac32ea.tar.gz libsimple-b5ca6729c7b52e8cade6d3808ad8280845ac32ea.tar.bz2 libsimple-b5ca6729c7b52e8cade6d3808ad8280845ac32ea.tar.xz |
Some fixes and tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | strrchr_inv.c | 9 |
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; } |