forked from starnakin/IronGOLEM
add: realloc and remove reallocarray
This commit is contained in:
24
tests/realloc.🗿
Normal file
24
tests/realloc.🗿
Normal file
@ -0,0 +1,24 @@
|
||||
main()
|
||||
{
|
||||
local ptr1;
|
||||
local ptr2;
|
||||
|
||||
name = "realloc";
|
||||
|
||||
ptr1 = strdup("yo");
|
||||
ptr2 = realloc(ptr1, 6);
|
||||
test_str("yo", ptr2, "standart: value");
|
||||
free(ptr2);
|
||||
test_num(leaks(), 0, "standart: leaks");
|
||||
|
||||
ptr2 = realloc(NULL, 6);
|
||||
test_num(heap + LOCATION_DATA, ptr2, "NULL: value");
|
||||
free(ptr2);
|
||||
test_num(leaks(), 0, "NULL: leaks");
|
||||
|
||||
ptr1 = strdup("bonjour");
|
||||
ptr2 = realloc(ptr1, 2);
|
||||
test_tab_num(ptr2, "bo", 2, "decrement size: value");
|
||||
free(ptr2);
|
||||
test_num(leaks(), 0, "decrement size: leaks");
|
||||
}
|
Reference in New Issue
Block a user