aboutsummaryrefslogtreecommitdiffstats
path: root/strends.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 /strends.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 'strends.c')
-rw-r--r--strends.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/strends.c b/strends.c
index 7be8714..e905451 100644
--- a/strends.c
+++ b/strends.c
@@ -7,3 +7,43 @@ libsimple_strends(const char *s, const char *t)
{
return memends(s, strlen(s), t, strlen(t));
}
+
+
+#ifdef TEST
+#include <assert.h>
+
+int
+main(void)
+{
+ assert(libsimple_strends("", "") == 1);
+ assert(libsimple_strends("test", "") == 1);
+ assert(libsimple_strends("", "test") == 0);
+ assert(libsimple_strends("test", "test") == 1);
+ assert(libsimple_strends("test", "testx") == 0);
+ assert(libsimple_strends("test", "est") == 1);
+ assert(libsimple_strends("test", "st") == 1);
+ assert(libsimple_strends("test", "t") == 1);
+ assert(libsimple_strends("test", "x") == 0);
+ assert(libsimple_strends("test", "xx") == 0);
+
+ assert(libsimple_strends("TEST", "") == 1);
+ assert(libsimple_strends("TEST", "test") == 0);
+ assert(libsimple_strends("TEST", "testx") == 0);
+ assert(libsimple_strends("TEST", "est") == 0);
+ assert(libsimple_strends("TEST", "st") == 0);
+ assert(libsimple_strends("TEST", "t") == 0);
+ assert(libsimple_strends("TEST", "x") == 0);
+ assert(libsimple_strends("TEST", "xx") == 0);
+
+ assert(libsimple_strends("", "TEST") == 0);
+ assert(libsimple_strends("test", "TEST") == 0);
+ assert(libsimple_strends("test", "TESTX") == 0);
+ assert(libsimple_strends("test", "EST") == 0);
+ assert(libsimple_strends("test", "ST") == 0);
+ assert(libsimple_strends("test", "T") == 0);
+ assert(libsimple_strends("test", "X") == 0);
+ assert(libsimple_strends("test", "XX") == 0);
+ return 0;
+}
+
+#endif