aboutsummaryrefslogtreecommitdiffstats
path: root/strstarts.c
diff options
context:
space:
mode:
Diffstat (limited to 'strstarts.c')
-rw-r--r--strstarts.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/strstarts.c b/strstarts.c
index ca44e52..f2db947 100644
--- a/strstarts.c
+++ b/strstarts.c
@@ -8,3 +8,43 @@ libsimple_strstarts(const char *s, const char *t)
for (; *t && *s == *t; s++, t++);
return !*t;
}
+
+
+#ifdef TEST
+#include <assert.h>
+
+int
+main(void)
+{
+ assert(libsimple_strstarts("", "") == 1);
+ assert(libsimple_strstarts("test", "") == 1);
+ assert(libsimple_strstarts("", "test") == 0);
+ assert(libsimple_strstarts("test", "test") == 1);
+ assert(libsimple_strstarts("test", "testx") == 0);
+ assert(libsimple_strstarts("test", "tes") == 1);
+ assert(libsimple_strstarts("test", "te") == 1);
+ assert(libsimple_strstarts("test", "t") == 1);
+ assert(libsimple_strstarts("test", "x") == 0);
+ assert(libsimple_strstarts("test", "xx") == 0);
+
+ assert(libsimple_strstarts("TEST", "") == 1);
+ assert(libsimple_strstarts("TEST", "test") == 0);
+ assert(libsimple_strstarts("TEST", "testx") == 0);
+ assert(libsimple_strstarts("TEST", "tes") == 0);
+ assert(libsimple_strstarts("TEST", "te") == 0);
+ assert(libsimple_strstarts("TEST", "t") == 0);
+ assert(libsimple_strstarts("TEST", "x") == 0);
+ assert(libsimple_strstarts("TEST", "xx") == 0);
+
+ assert(libsimple_strstarts("", "TEST") == 0);
+ assert(libsimple_strstarts("test", "TEST") == 0);
+ assert(libsimple_strstarts("test", "TESTX") == 0);
+ assert(libsimple_strstarts("test", "TES") == 0);
+ assert(libsimple_strstarts("test", "TE") == 0);
+ assert(libsimple_strstarts("test", "T") == 0);
+ assert(libsimple_strstarts("test", "X") == 0);
+ assert(libsimple_strstarts("test", "XX") == 0);
+ return 0;
+}
+
+#endif