aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:34:26 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:34:26 +1000
commita4385471decc41f4aa7ff39328b7aec1de4e9dc9 (patch)
treec1ee62a8dbc9daf330992394866eab9adced4cc2 /libc
parent147bcfbba9e9eaec215b5ad40e6bfb3fd57361dd (diff)
downloadskiboot-a4385471decc41f4aa7ff39328b7aec1de4e9dc9.zip
skiboot-a4385471decc41f4aa7ff39328b7aec1de4e9dc9.tar.gz
skiboot-a4385471decc41f4aa7ff39328b7aec1de4e9dc9.tar.bz2
add tests for libc strcasecmp
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/test/run-memops-test.c12
-rw-r--r--libc/test/run-memops.c15
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;
}