diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
commit | 27dae84ed92f1ef0300263091972338d12e78348 (patch) | |
tree | 7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /tests/test-strncat.c | |
parent | 4682deeb62247d34de87f8e777f99e2d337fd377 (diff) |
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'tests/test-strncat.c')
-rw-r--r-- | tests/test-strncat.c | 25 |
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; } |