diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-12 21:35:12 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-12 21:35:12 +0200 |
commit | 93b8428b5812191177c790ea9ffb9158d5a296b4 (patch) | |
tree | 8e43220208a7e3b4780a49b8278e731f3b5fcbbf /memrchr.c | |
parent | Add DONT_DEFINE_CLOCK_MONOTONIC_RAW (diff) | |
download | libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.gz libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.bz2 libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.xz |
Add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'memrchr.c')
-rw-r--r-- | memrchr.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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 <assert.h> + +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 |