add: strndup

This commit is contained in:
2023-06-18 18:06:17 +02:00
parent 370657c291
commit e7a752458f
2 changed files with 37 additions and 0 deletions

21
tests/strndup.🗿 Normal file
View File

@ -0,0 +1,21 @@
main()
{
local ptr;
name = "strndup";
ptr = strndup("bozoman", 7);
test_str(ptr, "bozoman", "");
free(ptr);
ptr = strndup("bozoman", 4);
test_str(ptr, "bozo", "");
free(ptr);
ptr = strndup("bozoman", 10);
test_str(ptr, "bozoman", "");
free(ptr);
ptr = strndup("bozoman", 0);
test_str(ptr, "", "");
free(ptr);
}