Commit 31d2760a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Rudimentary (incomplete) tests for block_Alloc/block_Realloc

parent 23510de8
...@@ -58,6 +58,27 @@ static void test_block_File (void) ...@@ -58,6 +58,27 @@ static void test_block_File (void)
remove ("testfile.txt"); remove ("testfile.txt");
} }
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));
assert (block != NULL);
assert (!strcmp (block->p_buffer, text + 10));
assert (block->i_buffer == sizeof (text));
block = block_Realloc (block, 10, sizeof (text));
assert (block != NULL);
assert (!strcmp (block->p_buffer + 10, text + 10));
assert (block->i_buffer == sizeof (text));
block_Release (block);
block = block_Alloc (SIZE_MAX);
assert (block == NULL);
}
int main (void) int main (void)
{ {
test_block_File (); test_block_File ();
......
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