Usermode/utests - Fix DNS utest, update libc utests to new format (no more EXP files)
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / TEST_string.c
1 /*
2  */
3 #include <stdio.h>
4 #include <string.h>
5 #include <utest_common.h>
6
7 int main()
8 {
9         TEST_REL_INT(0, > , strcmp("hello", "world"));
10         TEST_REL_INT(0, ==, strcmp("hello", "hello"));
11         TEST_REL_INT(0, < , strcmp("wello", "hello"));
12         TEST_REL_INT(0, < , strcmp("\xff", "\1"));
13         TEST_REL_INT(0, > , strcmp("\1", "\xff"));
14         TEST_REL_INT(0, > , strcmp("Hello", "hello"));
15         
16         TEST_REL_INT(0, ==, strncmp("hello world", "hello", 5));
17         
18         TEST_REL_INT(0, > , strcasecmp("hello", "world"));
19         TEST_REL_INT(0, ==, strcasecmp("hello", "hello"));
20         TEST_REL_INT(0, < , strcasecmp("wello", "hello"));
21         TEST_REL_INT(0, < , strcasecmp("\xff", "\1"));
22         TEST_REL_INT(0, > , strcasecmp("\1", "\xff"));
23         TEST_REL_INT(0, ==, strcasecmp("Hello", "hello"));
24         TEST_REL_INT(0, ==, strcasecmp("Hello", "Hello"));
25         TEST_REL_INT(0, ==, strcasecmp("hellO", "Hello"));
26         
27         char buf[13];
28         memset(buf, 127, sizeof(buf));
29         TEST_REL_INT(127, ==, buf[0]);
30         TEST_REL_INT(127, ==, buf[4]);
31         strncpy(buf, "hello", 4);
32         TEST_REL_INT('l', ==, buf[3]);
33         TEST_REL_INT(127, ==, buf[4]);
34         strncpy(buf, "hello", 8);
35         TEST_REL_INT('o', ==, buf[4]);
36         TEST_REL_INT('\0', ==, buf[5]);
37         TEST_REL_INT('\0', ==, buf[7]);
38         TEST_REL_INT(127, ==, buf[8]);
39         
40         memset(buf, 0, 13);
41         TEST_REL_INT(0, ==, buf[0]);
42         TEST_REL_INT(0, ==, buf[12]);
43         
44         TEST_REL_PTR(NULL, ==, memchr("\xffhello", 'x', 6));
45         
46         const char *teststr_foo = "foo";
47         TEST_REL_PTR(teststr_foo+0, ==, strchr(teststr_foo, 'f'));
48         TEST_REL_PTR(teststr_foo+1, ==, strchr(teststr_foo, 'o'));
49         TEST_REL_PTR(teststr_foo+3, ==, strchr(teststr_foo, '\0'));
50         TEST_REL_PTR(NULL, ==, strchr(teststr_foo, 'X'));
51         TEST_REL_PTR(teststr_foo+0, ==, strrchr(teststr_foo, 'f'));
52         TEST_REL_PTR(teststr_foo+2, ==, strrchr(teststr_foo, 'o'));
53         TEST_REL_PTR(teststr_foo+3, ==, strrchr(teststr_foo, '\0'));
54         TEST_REL_PTR(NULL, ==, strrchr(teststr_foo, 'X'));
55 }
56

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