Usermode/libc #6 Fix string.h functions, add some more unit tests
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / TEST_string.c
diff --git a/Usermode/Libraries/libc.so_src/TEST_string.c b/Usermode/Libraries/libc.so_src/TEST_string.c
new file mode 100644 (file)
index 0000000..46fcee5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ */
+#include <stdio.h>
+#include <string.h>
+
+#define ASSERT(cnd)    printf("ASSERT: "#cnd" == %s\n", ((cnd) ? "pass" : "FAIL"))
+
+int main()
+{
+       ASSERT(strcmp("hello", "world") < 0);
+       ASSERT(strcmp("hello", "hello") == 0);
+       ASSERT(strcmp("wello", "hello") > 0);
+       ASSERT(strcmp("\xff", "\1") > 0);
+       ASSERT(strcmp("\1", "\xff") < 0);
+       ASSERT(strcmp("Hello", "hello") < 0);
+       
+       ASSERT(strncmp("hello world", "hello", 5) == 0);
+       
+       ASSERT(strcasecmp("hello", "world") < 0);
+       ASSERT(strcasecmp("hello", "hello") == 0);
+       ASSERT(strcasecmp("wello", "hello") > 0);
+       ASSERT(strcasecmp("\xff", "\1") > 0);
+       ASSERT(strcasecmp("\1", "\xff") < 0);
+       ASSERT(strcasecmp("Hello", "hello") == 0);
+       ASSERT(strcasecmp("Hello", "Hello") == 0);
+       ASSERT(strcasecmp("hellO", "Hello") == 0);
+       
+       
+       char buf[13];
+       memset(buf, 0, 13);
+       ASSERT(buf[0] == 0);    ASSERT(buf[12] == 0);
+       
+       ASSERT(memchr("\xffhello", 'x', 6) == NULL);
+}
+

UCC git Repository :: git.ucc.asn.au