summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-11-22 22:16:06 +0000
committerEric Andersen <andersen@codepoet.org>2000-11-22 22:16:06 +0000
commit8cbc907e8221cbd625a3d9e9698fadfad6742fc2 (patch)
tree5b19b4c2a893df4fb91da29172c0cceb5517dd97 /test
parentc25724dc73a4a81cd610508da9e63cf4304dea25 (diff)
Add in an additional test for memcmp suggested by Mathias Lewin
<mln@sys.sigma.se> (I just checked in a fix for memcmp to make it pass).
Diffstat (limited to 'test')
-rw-r--r--test/string/string.c28
1 files changed, 19 insertions, 9 deletions
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