diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/test/run-memops-test.c | 12 | ||||
-rw-r--r-- | libc/test/run-memops.c | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/libc/test/run-memops-test.c b/libc/test/run-memops-test.c index 41c624f..e6fc7d0 100644 --- a/libc/test/run-memops-test.c +++ b/libc/test/run-memops-test.c @@ -47,6 +47,8 @@ int test_memset(char* buf, int c, size_t s); int test_memchr(const void *ptr, int c, size_t n, void* expected); int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected); int test_strcmp(const void *ptr1, const void *ptr2, int expected); +int test_strchr(const char *s, int c, char *expected); +int test_strcasecmp(const char *s1, const char *s2, int expected); int test_memset(char* buf, int c, size_t s) { @@ -75,3 +77,13 @@ int test_strcmp(const void *ptr1, const void *ptr2, int expected) { return(expected == strcmp(ptr1, ptr2)); } + +int test_strchr(const char *s, int c, char *expected) +{ + return(expected == strchr(s, c)); +} + +int test_strcasecmp(const char *s1, const char *s2, int expected) +{ + return(expected == strcasecmp(s1, s2)); +} diff --git a/libc/test/run-memops.c b/libc/test/run-memops.c index 259c4ff..50b2cab 100644 --- a/libc/test/run-memops.c +++ b/libc/test/run-memops.c @@ -25,6 +25,8 @@ int test_memset(char* buf, int c, size_t s); int test_memchr(const void *ptr, int c, size_t n, void* expected); int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected); int test_strcmp(const void *ptr1, const void *ptr2, int expected); +int test_strchr(const char *s, int c, char *expected); +int test_strcasecmp(const char *s1, const char *s2, int expected); int main(void) { @@ -53,7 +55,20 @@ int main(void) assert(test_strcmp(buf, "Hello World!", 0)); assert(test_strcmp(buf, "Hfllow World", -1)); + + assert(test_strchr(buf, 'H', buf)); + assert(test_strchr(buf, 'e', buf+1)); + assert(test_strchr(buf, 'a', NULL)); + assert(test_strchr(buf, '!', buf+11)); + + assert(test_strcasecmp(buf, "Hello World!", 0)); + assert(test_strcasecmp(buf, "HELLO WORLD!", 0)); + assert(test_strcasecmp(buf, "IELLO world!", -1)); + assert(test_strcasecmp(buf, "HeLLo WOrlc!", 1)); + + free(buf); + return 0; } |