Usermode/libc #6 Fix string.h functions, add some more unit tests
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / TEST_string.c
1 /*
2  */
3 #include <stdio.h>
4 #include <string.h>
5
6 #define ASSERT(cnd)     printf("ASSERT: "#cnd" == %s\n", ((cnd) ? "pass" : "FAIL"))
7
8 int main()
9 {
10         ASSERT(strcmp("hello", "world") < 0);
11         ASSERT(strcmp("hello", "hello") == 0);
12         ASSERT(strcmp("wello", "hello") > 0);
13         ASSERT(strcmp("\xff", "\1") > 0);
14         ASSERT(strcmp("\1", "\xff") < 0);
15         ASSERT(strcmp("Hello", "hello") < 0);
16         
17         ASSERT(strncmp("hello world", "hello", 5) == 0);
18         
19         ASSERT(strcasecmp("hello", "world") < 0);
20         ASSERT(strcasecmp("hello", "hello") == 0);
21         ASSERT(strcasecmp("wello", "hello") > 0);
22         ASSERT(strcasecmp("\xff", "\1") > 0);
23         ASSERT(strcasecmp("\1", "\xff") < 0);
24         ASSERT(strcasecmp("Hello", "hello") == 0);
25         ASSERT(strcasecmp("Hello", "Hello") == 0);
26         ASSERT(strcasecmp("hellO", "Hello") == 0);
27         
28         
29         char buf[13];
30         memset(buf, 0, 13);
31         ASSERT(buf[0] == 0);    ASSERT(buf[12] == 0);
32         
33         ASSERT(memchr("\xffhello", 'x', 6) == NULL);
34 }
35

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