]> git.sesse.net Git - vlc/blobdiff - src/test/test_block.c
Rudimentary (incomplete) tests for block_Alloc/block_Realloc
[vlc] / src / test / test_block.c
index f594d06d72b8b5ef4a562e2ddc4721a795616e9c..970d10edb03c1d2146de78de9cb1da2b2c0fa941 100644 (file)
@@ -58,6 +58,27 @@ static void test_block_File (void)
     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)
 {
     test_block_File ();