From 8cbc907e8221cbd625a3d9e9698fadfad6742fc2 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 22 Nov 2000 22:16:06 +0000 Subject: Add in an additional test for memcmp suggested by Mathias Lewin (I just checked in a fix for memcmp to make it pass). --- test/string/string.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'test/string') diff --git a/test/string/string.c b/test/string/string.c index c59262717..43a1108b3 100644 --- a/test/string/string.c +++ b/test/string/string.c @@ -616,15 +616,25 @@ test_strsep (void) void test_memcmp (void) { - it = "memcmp"; - check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ - check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ - check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ - check(memcmp("abce", "abcd", 4) > 0, 4); - check(memcmp("alph", "beta", 4) < 0, 5); - check(memcmp("a\203", "a\003", 2) > 0, 6); - check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ - check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ + int foo[6] = {'\0','0','1','2','3','4'}; + int bar[6] = {'\0','0','1','2','3','5'}; + + it = "memcmp"; + check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ + check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ + check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ + check(memcmp("abce", "abcd", 4) > 0, 4); + check(memcmp("alph", "beta", 4) < 0, 5); + check(memcmp("a\203", "a\003", 2) > 0, 6); + check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ + check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ + + check(memcmp(foo, bar, 5*(sizeof(int))) == 0, 9); /* non-string test + case (both begin + with a NULL) */ + check(memcmp(foo, bar, 6*(sizeof(int))) < 0, 10); /* non-string test + case (both begin + with a NULL) */ } void -- cgit v1.2.3