Commit 4ddb539e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Improve/fix block_Realloc() cases

parent 2d15a4ba
......@@ -63,16 +63,21 @@ static void test_block (void)
block_t *block = block_Alloc (sizeof (text));
assert (block != NULL);
strcpy (block->p_buffer, text);
block = block_Realloc (block, -10, sizeof (text));
memcpy (block->p_buffer, text, sizeof (text));
block = block_Realloc (block, 0, sizeof (text));
assert (block != NULL);
assert (!strcmp (block->p_buffer, text + 10));
assert (block->i_buffer == sizeof (text));
assert (!memcmp (block->p_buffer, text, sizeof (text)));
block = block_Realloc (block, 10, sizeof (text));
block = block_Realloc (block, 200, sizeof (text) + 200);
assert (block != NULL);
assert (block->i_buffer == 200 + sizeof (text) + 200);
assert (!memcmp (block->p_buffer + 200, text, sizeof (text)));
block = block_Realloc (block, -200, sizeof (text));
assert (block != NULL);
assert (!strcmp (block->p_buffer + 10, text + 10));
assert (block->i_buffer == sizeof (text));
assert (!memcmp (block->p_buffer, text, sizeof (text)));
block_Release (block);
block = block_Alloc (SIZE_MAX);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment