summaryrefslogtreecommitdiff
path: root/tests/test-strncat.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-10-18 19:07:08 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-10-18 19:07:08 +0200
commit693ae7b71dfdd1a8146266b5794a71c0dbe5dff0 (patch)
tree9704e2f7bd8962ea8911cd6f4e2d37227d7eff2e /tests/test-strncat.c
parentb8b9b0ac61ac47dddc58717f23619f8b06640498 (diff)
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
Update upstream source from tag 'upstream/1.4.1'
Update to upstream version '1.4.1' with Debian dir 8add41ffbfe3e6636eec0ec134c5af96832cc143
Diffstat (limited to 'tests/test-strncat.c')
-rw-r--r--tests/test-strncat.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test-strncat.c b/tests/test-strncat.c
index 0ee5089e..7b2e682a 100644
--- a/tests/test-strncat.c
+++ b/tests/test-strncat.c
@@ -1,5 +1,5 @@
/* Test of strncat() function.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,6 +28,17 @@ SIGNATURE_CHECK (strncat, char *, (char *, const char *, size_t));
#include "zerosize-ptr.h"
#include "macros.h"
+/* Test the library, not the compiler+library. */
+static char *
+lib_strncat (char *s1, char const *s2, size_t n)
+{
+ return strncat (s1, s2, n);
+}
+static char *(*volatile volatile_strncat) (char *, char const *, size_t)
+ = lib_strncat;
+#undef strncat
+#define strncat volatile_strncat
+
#define UNIT char
#define U_STRNCAT strncat
#define MAGIC ((char) 0xBA)
@@ -58,5 +69,17 @@ main ()
check (input, SIZEOF (input));
}
+ /* Test zero-length operations on NULL pointers, allowed by
+ <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
+
+#if 0 /* I think this is invalid, per ISO C 23 § 7.26.3.2. */
+ ASSERT (strncat (NULL, "x", 0) == NULL);
+#endif
+
+ {
+ char y[2] = { 'x', '\0' };
+ ASSERT (strncat (y, NULL, 0) == y);
+ }
+
return test_exit_status;
}