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
index 4ecca30..eb940c7 100644 (file)
@@ -2,50 +2,55 @@
  */
 #include <stdio.h>
 #include <string.h>
-
-#define ASSERT(cnd)    printf("ASSERT: "#cnd" == %s\n", ((cnd) ? "pass" : "FAIL"))
+#include <utest_common.h>
 
 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);
+       TEST_REL_INT(0, > , strcmp("hello", "world"));
+       TEST_REL_INT(0, ==, strcmp("hello", "hello"));
+       TEST_REL_INT(0, < , strcmp("wello", "hello"));
+       TEST_REL_INT(0, < , strcmp("\xff", "\1"));
+       TEST_REL_INT(0, > , strcmp("\1", "\xff"));
+       TEST_REL_INT(0, > , strcmp("Hello", "hello"));
        
-       ASSERT(strncmp("hello world", "hello", 5) == 0);
+       TEST_REL_INT(0, ==, strncmp("hello world", "hello", 5));
        
-       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);
+       TEST_REL_INT(0, > , strcasecmp("hello", "world"));
+       TEST_REL_INT(0, ==, strcasecmp("hello", "hello"));
+       TEST_REL_INT(0, < , strcasecmp("wello", "hello"));
+       TEST_REL_INT(0, < , strcasecmp("\xff", "\1"));
+       TEST_REL_INT(0, > , strcasecmp("\1", "\xff"));
+       TEST_REL_INT(0, ==, strcasecmp("Hello", "hello"));
+       TEST_REL_INT(0, ==, strcasecmp("Hello", "Hello"));
+       TEST_REL_INT(0, ==, strcasecmp("hellO", "Hello"));
        
        char buf[13];
        memset(buf, 127, sizeof(buf));
-       ASSERT(buf[0] == 127);  ASSERT(buf[4] == 127);
+       TEST_REL_INT(127, ==, buf[0]);
+       TEST_REL_INT(127, ==, buf[4]);
        strncpy(buf, "hello", 4);
-       ASSERT(buf[3] == 'l');  ASSERT(buf[4] == 127);
+       TEST_REL_INT('l', ==, buf[3]);
+       TEST_REL_INT(127, ==, buf[4]);
        strncpy(buf, "hello", 8);
-       ASSERT(buf[4] == 'o');  ASSERT(buf[5] == '\0'); ASSERT(buf[7] == '\0'); ASSERT(buf[8] == 127);
+       TEST_REL_INT('o', ==, buf[4]);
+       TEST_REL_INT('\0', ==, buf[5]);
+               TEST_REL_INT('\0', ==, buf[7]);
+               TEST_REL_INT(127, ==, buf[8]);
        
        memset(buf, 0, 13);
-       ASSERT(buf[0] == 0);    ASSERT(buf[12] == 0);
+       TEST_REL_INT(0, ==, buf[0]);
+       TEST_REL_INT(0, ==, buf[12]);
        
-       ASSERT(memchr("\xffhello", 'x', 6) == NULL);
+       TEST_REL_PTR(NULL, ==, memchr("\xffhello", 'x', 6));
        
        const char *teststr_foo = "foo";
-       ASSERT(strchr(teststr_foo, 'f') == teststr_foo+0);
-       ASSERT(strchr(teststr_foo, 'o') == teststr_foo+1);
-       ASSERT(strchr(teststr_foo, '\0') == teststr_foo+3);
-       ASSERT(strchr(teststr_foo, 'X') == NULL);
-       ASSERT(strrchr(teststr_foo, 'f') == teststr_foo+0);
-       ASSERT(strrchr(teststr_foo, 'o') == teststr_foo+2);
-       ASSERT(strrchr(teststr_foo, '\0') == teststr_foo+3);
-       ASSERT(strrchr(teststr_foo, 'X') == NULL);
+       TEST_REL_PTR(teststr_foo+0, ==, strchr(teststr_foo, 'f'));
+       TEST_REL_PTR(teststr_foo+1, ==, strchr(teststr_foo, 'o'));
+       TEST_REL_PTR(teststr_foo+3, ==, strchr(teststr_foo, '\0'));
+       TEST_REL_PTR(NULL, ==, strchr(teststr_foo, 'X'));
+       TEST_REL_PTR(teststr_foo+0, ==, strrchr(teststr_foo, 'f'));
+       TEST_REL_PTR(teststr_foo+2, ==, strrchr(teststr_foo, 'o'));
+       TEST_REL_PTR(teststr_foo+3, ==, strrchr(teststr_foo, '\0'));
+       TEST_REL_PTR(NULL, ==, strrchr(teststr_foo, 'X'));
 }
 

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