From 93b8428b5812191177c790ea9ffb9158d5a296b4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 12 Aug 2018 21:35:12 +0200 Subject: Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- memrchr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'memrchr.c') diff --git a/memrchr.c b/memrchr.c index 6beec6d..454ad4c 100644 --- a/memrchr.c +++ b/memrchr.c @@ -10,3 +10,18 @@ libsimple_memrchr(const void *s_, int c, size_t n_) while (n-- && (int)s[n] != c); return n < 0 ? NULL : &s[n]; } + + +#ifdef TEST +#include + +int +main(void) +{ + assert(!strcmp(libsimple_memrchr("1234512345", '3', sizeof("1234512345") - 1), "345")); + assert(!strcmp(libsimple_memrchr("1234512345", '5', sizeof("1234512345") - 1), "5")); + assert(!libsimple_memrchr("1234512345", 'x', sizeof("1234512345") - 1)); + return 0; +} + +#endif -- cgit v1.2.3-70-g09d2