diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:07:35 +0200 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:07:35 +0200 |
| commit | fa23d938c040bc8af305a31fa874df55b2a02576 (patch) | |
| tree | 9704e2f7bd8962ea8911cd6f4e2d37227d7eff2e /tests/test-strncat.c | |
| parent | df9dbf9b0915e432a4a2c4182f60af36374eaaab (diff) | |
| parent | 693ae7b71dfdd1a8146266b5794a71c0dbe5dff0 (diff) | |
Merge branch 'feature/upstream' into develop
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; } |
