mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
tests: add some basic checks for gst_buffer_fill()
This commit is contained in:
parent
65c2ecb4f3
commit
913b1e6f20
1 changed files with 39 additions and 0 deletions
|
@ -742,6 +742,44 @@ GST_START_TEST (test_find)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_fill)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
guint8 data[1024], data2[25];
|
||||
gint i;
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
gst_buffer_append_memory (buf, gst_allocator_alloc (NULL, 0, NULL));
|
||||
gst_buffer_append_memory (buf, gst_allocator_alloc (NULL, 10, NULL));
|
||||
gst_buffer_append_memory (buf, gst_allocator_alloc (NULL, 15, NULL));
|
||||
gst_buffer_append_memory (buf, gst_allocator_alloc (NULL, 0, NULL));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (data); ++i)
|
||||
data[i] = i & 0xff;
|
||||
|
||||
/* a NULL src pointer should be ok if the src length is 0 bytes */
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, NULL, 0), 0);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 20, NULL, 0), 0);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 0), 0);
|
||||
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 1), 1);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 11), 11);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 15), 15);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 25), 25);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data, 26), 25);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 1, data, 26), 24);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 10, data, 100), 15);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 11, data, 100), 14);
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 25, data, 100), 0);
|
||||
|
||||
fail_unless_equals_int (gst_buffer_fill (buf, 0, data + 10, 25), 25);
|
||||
fail_unless_equals_int (gst_buffer_extract (buf, 0, data2, 25), 25);
|
||||
fail_unless (memcmp (data2, data + 10, 25) == 0);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_buffer_suite (void)
|
||||
|
@ -761,6 +799,7 @@ gst_buffer_suite (void)
|
|||
tcase_add_test (tc_chain, test_resize);
|
||||
tcase_add_test (tc_chain, test_map);
|
||||
tcase_add_test (tc_chain, test_find);
|
||||
tcase_add_test (tc_chain, test_fill);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue