aboutsummaryrefslogtreecommitdiffstats
path: root/rawmemrchr.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-12 21:35:12 +0200
committerMattias Andrée <maandree@kth.se>2018-08-12 21:35:12 +0200
commit93b8428b5812191177c790ea9ffb9158d5a296b4 (patch)
tree8e43220208a7e3b4780a49b8278e731f3b5fcbbf /rawmemrchr.c
parentAdd DONT_DEFINE_CLOCK_MONOTONIC_RAW (diff)
downloadlibsimple-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 'rawmemrchr.c')
-rw-r--r--rawmemrchr.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/rawmemrchr.c b/rawmemrchr.c
index 5ce374d..3985840 100644
--- a/rawmemrchr.c
+++ b/rawmemrchr.c
@@ -9,3 +9,17 @@ libsimple_rawmemrchr(const void *s_, int c, size_t n)
while ((int)s[--n] != c);
return &s[n];
}
+
+
+#ifdef TEST
+#include <assert.h>
+
+int
+main(void)
+{
+ assert(!strcmp(libsimple_rawmemrchr("1234512345", '3', sizeof("1234512345") - 1), "345"));
+ assert(!strcmp(libsimple_rawmemrchr("1234512345", '5', sizeof("1234512345") - 1), "5"));
+ return 0;
+}
+
+#endif