1 /* Tests for some interesting cases in non-standard strlcpy(). */
11 char *src
= malloc(100);
13 fprintf(stderr
, "Memory allocation failure.\n");
16 strcpy(src
, "Hey, dude!");
18 char *dst
= malloc(10);
20 fprintf(stderr
, "Memory allocation failure.\n");
25 copied
= strlcpy(dst
, src
, 10);
27 fprintf(stderr
, "Expected 10 but got %zu for test #1.\n", copied
);
29 /* Here dst is not large enough. */
30 copied
= strlcpy(dst
, src
, strlen(src
) + 1);
32 fprintf(stderr
, "Expected 10 but got %zu for test #2.\n", copied
);
34 /* This is just a fancy way how to write strlen(src).
35 Undocumented but heavily used. */
36 copied
= strlcpy(NULL
, src
, 0);
38 fprintf(stderr
, "Expected 10 but got %zu for test #3.\n", copied
);
40 /* Source and destination overlap. */
41 strlcpy(src
+ 9, src
, strlen(src
) + 1);
42 /* Return value is not checked because function behaviour
43 is undefined in such case (and valgrind's differs). */