]> git.sur5r.net Git - cc65/commitdiff
initial check-in
authorcpg <cpg@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 10 Feb 2009 19:16:52 +0000 (19:16 +0000)
committercpg <cpg@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 10 Feb 2009 19:16:52 +0000 (19:16 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3926 b7a2c559-68d2-44c3-8de9-860c34a00d81

testcode/lib/strnicmp-test.c [new file with mode: 0644]

diff --git a/testcode/lib/strnicmp-test.c b/testcode/lib/strnicmp-test.c
new file mode 100644 (file)
index 0000000..45c2ce2
--- /dev/null
@@ -0,0 +1,80 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef __ATARI__
+#include <atari.h>
+#include <conio.h>
+#endif
+
+static int do_test(const char *s1, const char *s2, size_t n)
+{
+    printf("strnicmp(\"%s\", \"%s\", %d):  ", s1, s2, (int)n);
+    return strncasecmp(s1, s2, n);
+}
+
+int main(void)
+{
+    int ret;
+
+    ret = do_test("Wurzl", "wURZL", 5);
+    if (ret)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("Wurzl", "wURZL", 6);
+    if (ret)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("Wurzl", "wURZL", 10);
+    if (ret)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("Wurzla", "wURZLB", 10);
+    if (ret >= 0)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("Wurzla", "wURZLb", 5);
+    if (ret)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("BLI", "bla", 5);
+    if (ret <= 0)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("", "bla", 5);
+    if (ret >= 0)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("BLI", "", 5);
+    if (ret <= 0)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+    ret = do_test("", "", 5);
+    if (ret)
+        printf("fail (%d)\n", ret);
+    else
+        printf("OK (%d)\n", ret);
+
+#ifdef __ATARI__
+    if (_dos_type != 1) {
+        cgetc();
+    }
+#endif
+
+    return 0;
+}