about summary refs log tree commit diff
path: root/string
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-05-11 08:55:42 +0000
committerUlrich Drepper <drepper@redhat.com>2008-05-11 08:55:42 +0000
commit3490f01de4df5e6b21a9da5a566913f20326fa7a (patch)
tree1a891e9a54a2390486337dc318700c109ab98c1c /string
parentcdffaaa61555d4b1b102b1a86be7f257be405ed6 (diff)
downloadglibc-3490f01de4df5e6b21a9da5a566913f20326fa7a.tar.gz
glibc-3490f01de4df5e6b21a9da5a566913f20326fa7a.tar.xz
glibc-3490f01de4df5e6b21a9da5a566913f20326fa7a.zip
* string/tester.c (test_memcmp): Add a few more tests.
	Patch by Mats Erik Andersson <ynglingatal@comhem.se>.
Diffstat (limited to 'string')
-rw-r--r--string/tester.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/string/tester.c b/string/tester.c
index 1c0efe07d4..773e969a35 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -985,15 +985,33 @@ test_strsep (void)
 static void
 test_memcmp (void)
 {
+  int cnt = 1;
+  char one[21];
+  char two[21];
+  
   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("a", "a", 1) == 0, cnt++);	/* Identity. */
+  check(memcmp("abc", "abc", 3) == 0, cnt++);	/* Multicharacter. */
+  check(memcmp("abcd", "abcf", 4) < 0, cnt++);	/* Honestly unequal. */
+  check(memcmp("abcf", "abcd", 4) > 0, cnt++);
+  check(memcmp("alph", "cold", 4) < 0, cnt++);
+  check(memcmp("a\203", "a\003", 2) > 0, cnt++);
+  check(memcmp("a\003", "a\203", 2) < 0, cnt++);
+  check(memcmp("a\003bc", "a\203bc", 2) < 0, cnt++);
+  check(memcmp("abc\203", "abc\003", 4) > 0, cnt++);
+  check(memcmp("abc\003", "abc\203", 4) < 0, cnt++);
+  check(memcmp("abcf", "abcd", 3) == 0, cnt++);	/* Count limited. */
+  check(memcmp("abc", "def", 0) == 0, cnt++);	/* Zero count. */
+  /* Comparisons with shifting 4-byte boundaries. */
+  for (int i = 0; i < 4; ++i)
+    {
+      char *a = one + i;
+      char *b = two + i;
+      strncpy(a, "--------11112222", 16);
+      strncpy(b, "--------33334444", 16);
+      check(memcmp(b, a, 16) > 0, cnt++);
+      check(memcmp(a, b, 16) < 0, cnt++);
+    }
 }
 
 static void