test-strxcpyx: add test for strpcpyf overflow

This fails before 'strxcpyx: don't overflow dest on strpcpyf truncate'.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-07-03 20:50:14 -04:00
parent f91049d5d7
commit 54d46a789e
+7
View File
@@ -51,6 +51,13 @@ static void test_strpcpyf(void) {
assert_se(streq(target, "space left: 25. foobar"));
assert_se(space_left == 3);
/* test overflow */
s = target;
space_left = strpcpyf(&s, 12, "00 left: %i. ", 999);
assert_se(streq(target, "00 left: 99"));
assert_se(space_left == 0);
assert_se(target[12] == '2');
}
static void test_strpcpyl(void) {