From: RĂ©mi Denis-Courmont Date: Sun, 30 Aug 2009 15:41:45 +0000 (+0300) Subject: Improve/fix block_Realloc() cases X-Git-Tag: 1.1.0-ff~3725 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4ddb539e3aab67ac6d6096c63999291f03bc8b67;p=vlc Improve/fix block_Realloc() cases --- diff --git a/src/test/test_block.c b/src/test/test_block.c index 970d10edb0..e0a3648f63 100644 --- a/src/test/test_block.c +++ b/src/test/test_block.c @@ -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);