Check for results of repeated calls to strnsubst(), as well as for the

behaviour with NULL match string, as that has changed over time.
This commit is contained in:
Juli Mallett 2002-06-22 12:58:42 +00:00
parent af03a3cbd6
commit 5058dcb497
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98616

View File

@ -73,14 +73,25 @@ strnsubst(char **str, const char *match, const char *replstr, size_t maxsize)
int
main(void)
{
char *x, *y;
char *x, *y, *z, *za;
y = x = "{}{}{}";
strnsubst(&x, "{}", "v ybir whyv! ", 12);
if (strcmp(x, "v ybir whyv! ") == 0)
printf("strnsubst() seems to work as expected.\n");
printf("x: %s\ny: %s\n", x, y);
x = "{}%$";
strnsubst(&x, "%$", "{} enpury!", 255);
y = x;
strnsubst(&y, "}{}", "ybir", 255);
z = y;
strnsubst(&z, "{", "v ", 255);
za = z;
strnsubst(&z, NULL, za, 255);
if (strcmp(z, "v ybir enpury!") == 0)
printf("strnsubst() seems to work!\n");
else
printf("strnsubst() is broken.\n");
printf("%s\n", z);
free(x);
free(y);
free(z);
free(za);
return 0;
}
#endif