[vlc-devel] commit: Improve/fix block_Realloc() cases ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Aug 30 17:42:51 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 30 18:41:45 2009 +0300| [4ddb539e3aab67ac6d6096c63999291f03bc8b67] | committer: Rémi Denis-Courmont 

Improve/fix block_Realloc() cases

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4ddb539e3aab67ac6d6096c63999291f03bc8b67
---

 src/test/test_block.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/test/test_block.c b/src/test/test_block.c
index 970d10e..e0a3648 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);




More information about the vlc-devel mailing list