aboutsummaryrefslogtreecommitdiffstats
path: root/memrchr.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-10-21 15:38:00 +0200
committerMattias Andrée <maandree@kth.se>2018-10-21 18:15:34 +0200
commit5f5e216a4abae6860f40c6bedd37db275dbb92d0 (patch)
tree3f22ab92c57fbac30c14d548cd545ed1ec77f395 /memrchr.c
parentm (diff)
downloadlibsimple-5f5e216a4abae6860f40c6bedd37db275dbb92d0.tar.gz
libsimple-5f5e216a4abae6860f40c6bedd37db275dbb92d0.tar.bz2
libsimple-5f5e216a4abae6860f40c6bedd37db275dbb92d0.tar.xz
Add rawmemcasechr and memrcasechr
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'memrchr.c')
-rw-r--r--memrchr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/memrchr.c b/memrchr.c
index 30c818e..36385ec 100644
--- a/memrchr.c
+++ b/memrchr.c
@@ -19,9 +19,15 @@ libsimple_memrchr(const void *s_, int c_, size_t n_)
int
main(void)
{
- assert(!strcmpnul(libsimple_memrchr("1234512345", '3', sizeof("1234512345") - 1), "345"));
- assert(!strcmpnul(libsimple_memrchr("1234512345", '5', sizeof("1234512345") - 1), "5"));
- assert(!libsimple_memrchr("1234512345", 'x', sizeof("1234512345") - 1));
+ assert(!strcmpnul(libsimple_memrchr("abcABCabcABC", 'a', sizeof("abcABCabcABC") - 1), "abcABC"));
+ assert(!strcmpnul(libsimple_memrchr("abcABCabcABC", 'c', sizeof("abcABCabcABC") - 1), "cABC"));
+ assert(!strcmpnul(libsimple_memrchr("abcABCabcABC", 'A', sizeof("abcABCabcABC") - 1), "ABC"));
+ assert(!strcmpnul(libsimple_memrchr("abcABCabcABC", 'C', sizeof("abcABCabcABC") - 1), "C"));
+ assert(!strcmpnul(libsimple_memrchr("ABCabcABCabc", 'a', sizeof("ABCabcABCabc") - 1), "abc"));
+ assert(!strcmpnul(libsimple_memrchr("ABCabcABCabc", 'c', sizeof("ABCabcABCabc") - 1), "c"));
+ assert(!strcmpnul(libsimple_memrchr("ABCabcABCabc", 'A', sizeof("ABCabcABCabc") - 1), "ABCabc"));
+ assert(!strcmpnul(libsimple_memrchr("ABCabcABCabc", 'C', sizeof("ABCabcABCabc") - 1), "Cabc"));
+ assert(!libsimple_memrchr("abcABCabcABC", 'x', sizeof("abcABCabcABC") - 1));
return 0;
}