aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:41:04 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:41:04 +1000
commit9c7f0d09eb4850b1828720846b07433b745ba526 (patch)
tree040e4f82898b8cb0f8037f1f1b75cb633d0ca20e
parenta4385471decc41f4aa7ff39328b7aec1de4e9dc9 (diff)
downloadskiboot-9c7f0d09eb4850b1828720846b07433b745ba526.zip
skiboot-9c7f0d09eb4850b1828720846b07433b745ba526.tar.gz
skiboot-9c7f0d09eb4850b1828720846b07433b745ba526.tar.bz2
add tests for libc strncasecmp
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--libc/test/run-memops-test.c6
-rw-r--r--libc/test/run-memops.c11
2 files changed, 17 insertions, 0 deletions
diff --git a/libc/test/run-memops-test.c b/libc/test/run-memops-test.c
index e6fc7d0..a4179eb 100644
--- a/libc/test/run-memops-test.c
+++ b/libc/test/run-memops-test.c
@@ -49,6 +49,7 @@ 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_strncasecmp(const char *s1, const char *s2, size_t n, int expected);
int test_memset(char* buf, int c, size_t s)
{
@@ -87,3 +88,8 @@ int test_strcasecmp(const char *s1, const char *s2, int expected)
{
return(expected == strcasecmp(s1, s2));
}
+
+int test_strncasecmp(const char *s1, const char *s2, size_t n, int expected)
+{
+ return(expected == strncasecmp(s1, s2, n));
+}
diff --git a/libc/test/run-memops.c b/libc/test/run-memops.c
index 50b2cab..21f6ab6 100644
--- a/libc/test/run-memops.c
+++ b/libc/test/run-memops.c
@@ -27,6 +27,7 @@ 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_strncasecmp(const char *s1, const char *s2, size_t n, int expected);
int main(void)
{
@@ -66,6 +67,16 @@ int main(void)
assert(test_strcasecmp(buf, "IELLO world!", -1));
assert(test_strcasecmp(buf, "HeLLo WOrlc!", 1));
+ assert(test_strncasecmp(buf, "Hello World!", strlen(buf), 0));
+ assert(test_strncasecmp(buf, "HELLO WORLD!", strlen(buf), 0));
+ assert(test_strncasecmp(buf, "IELLO world!", strlen(buf), -1));
+ assert(test_strncasecmp(buf, "HeLLo WOrlc!", strlen(buf), 1));
+
+ assert(test_strncasecmp(buf, "HeLLo WOrlc!", 0, 0));
+ assert(test_strncasecmp(buf, "HeLLo WOrlc!", 1, 0));
+ assert(test_strncasecmp(buf, "HeLLo WOrlc!", 2, 0));
+ assert(test_strncasecmp(buf, "HeLLp WOrlc!", 5, -1));
+
free(buf);