diff options
Diffstat (limited to 'src/test/test-strxcpyx.c')
-rw-r--r-- | src/test/test-strxcpyx.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c index 21d56d9be6..d7199124a3 100644 --- a/src/test/test-strxcpyx.c +++ b/src/test/test-strxcpyx.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ +#include <stdio.h> #include <string.h> #include "string-util.h" @@ -78,6 +79,24 @@ static void test_strscpyl(void) { assert_se(space_left == 10); } +static void test_sd_event_code_migration(void) { + char b[100 * DECIMAL_STR_MAX(unsigned) + 1]; + char c[100 * DECIMAL_STR_MAX(unsigned) + 1], *p; + unsigned i; + size_t l; + int o; + + for (i = o = 0; i < 100; i++) + o += snprintf(&b[o], sizeof(b) - o, "%u ", i); + + p = c; + l = sizeof(c); + for (i = 0; i < 100; i++) + l = strpcpyf(&p, l, "%u ", i); + + assert_se(streq(b, c)); +} + int main(int argc, char *argv[]) { test_strpcpy(); test_strpcpyf(); @@ -85,5 +104,7 @@ int main(int argc, char *argv[]) { test_strscpy(); test_strscpyl(); + test_sd_event_code_migration(); + return 0; } |