X-Git-Url: https://git.ucc.asn.au/?p=tpg%2Facess2.git;a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2FTEST_string.c;h=eb940c7edc9fb6a3de7ec070ac47b68784bbcd52;hp=4ecca307d684819ece57ff7b12de56fe12834f64;hb=db55040ba8814edf681d4ccc12ad8955d8aa404a;hpb=bdab8e5cebaf249d291d19523d0358f8c1c98008 diff --git a/Usermode/Libraries/libc.so_src/TEST_string.c b/Usermode/Libraries/libc.so_src/TEST_string.c index 4ecca307..eb940c7e 100644 --- a/Usermode/Libraries/libc.so_src/TEST_string.c +++ b/Usermode/Libraries/libc.so_src/TEST_string.c @@ -2,50 +2,55 @@ */ #include #include - -#define ASSERT(cnd) printf("ASSERT: "#cnd" == %s\n", ((cnd) ? "pass" : "FAIL")) +#include 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')); }