]> Savannah Git Hosting - gnulib.git/commitdiff
wmemcmp tests: Verify N3322 functionality.
authorBruno Haible <bruno@clisp.org>
Tue, 5 Nov 2024 20:12:08 +0000 (21:12 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 5 Nov 2024 21:38:53 +0000 (22:38 +0100)
* tests/test-wmemcmp.c (main): Add zero-size tests.

ChangeLog
tests/test-wmemcmp.c

index 0efaf7854b1a44e94371c2df485b9374c454b10b..6945b84e9eb7d27b62fbb482c31af27c9ca1ca10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-11-05  Bruno Haible  <bruno@clisp.org>
+
+       wmemcmp tests: Verify N3322 functionality.
+       * tests/test-wmemcmp.c (main): Add zero-size tests.
+
 2024-11-05  Bruno Haible  <bruno@clisp.org>
 
        wcsncmp tests: Verify N3322 functionality.
index 692fcb5e07fc47a95ab09c8dab0c618c4b908096..d7992b59ce2285175e021cc36e0ee91859822871 100644 (file)
@@ -91,5 +91,19 @@ main (int argc, char *argv[])
     ASSERT (wmemcmp (input2, input1, 1) > 0);
   }
 
+  int volatile value;
+
+  /* Test zero-length operations on NULL pointers, allowed by
+     <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>.  */
+
+  value = (wmemcmp (NULL, L"x", 0) == 0);
+  ASSERT (value);
+
+  value = (wmemcmp (L"x", NULL, 0) == 0);
+  ASSERT (value);
+
+  value = (wmemcmp (NULL, NULL, 0) == 0);
+  ASSERT (value);
+
   return test_exit_status;
 }