From 147bcfbba9e9eaec215b5ad40e6bfb3fd57361dd Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Wed, 24 Jun 2015 13:28:21 +1000 Subject: add tests for libc strcmp Signed-off-by: Stewart Smith --- libc/test/run-memops-test.c | 6 ++++++ libc/test/run-memops.c | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'libc') diff --git a/libc/test/run-memops-test.c b/libc/test/run-memops-test.c index c848a1d..41c624f 100644 --- a/libc/test/run-memops-test.c +++ b/libc/test/run-memops-test.c @@ -46,6 +46,7 @@ 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_memset(char* buf, int c, size_t s) { @@ -69,3 +70,8 @@ int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected) { return(expected == memcmp(ptr1, ptr2, n)); } + +int test_strcmp(const void *ptr1, const void *ptr2, int expected) +{ + return(expected == strcmp(ptr1, ptr2)); +} diff --git a/libc/test/run-memops.c b/libc/test/run-memops.c index ded21ae..259c4ff 100644 --- a/libc/test/run-memops.c +++ b/libc/test/run-memops.c @@ -24,6 +24,7 @@ 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 main(void) { @@ -49,6 +50,9 @@ int main(void) assert(test_memcmp(buf, "Hello World!", strlen(buf), 0)); assert(test_memcmp(buf, "Hfllow World", strlen(buf), -1)); + + assert(test_strcmp(buf, "Hello World!", 0)); + assert(test_strcmp(buf, "Hfllow World", -1)); free(buf); return 0; -- cgit v1.1