summaryrefslogtreecommitdiff
path: root/tests/test-strncat.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-10 13:24:07 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-10 13:24:07 +0100
commitcfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch)
tree8016486f8ee7157213f2d09ff2491bfa9c94638a /tests/test-strncat.c
parent14e4d584d0121031ec40e6c35869745f1747ff29 (diff)
parent1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff)
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
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..ccf65197 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-2026 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;
}