mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
tests: add unit test for gst_adapter_take_buffer_list()
This commit is contained in:
parent
e6a0f52e3c
commit
b1b718c6d0
1 changed files with 48 additions and 0 deletions
|
@ -807,6 +807,53 @@ GST_START_TEST (test_take_list)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
/* Fill a buffer with a sequence of 32 bit ints and read them back out
|
||||
* using take_buffer, checking that they're still in the right order */
|
||||
GST_START_TEST (test_take_buffer_list)
|
||||
{
|
||||
GstAdapter *adapter;
|
||||
int i = 0;
|
||||
|
||||
adapter = create_and_fill_adapter ();
|
||||
while (gst_adapter_available (adapter) >= sizeof (guint32)) {
|
||||
GstBufferList *buffer_list;
|
||||
GstBuffer *buf;
|
||||
gsize left;
|
||||
GstMapInfo info;
|
||||
guint8 *ptr;
|
||||
guint n, num;
|
||||
|
||||
buffer_list = gst_adapter_take_buffer_list (adapter, sizeof (guint32) * 5);
|
||||
fail_unless (buffer_list != NULL);
|
||||
num = gst_buffer_list_length (buffer_list);
|
||||
fail_unless (num > 0);
|
||||
|
||||
for (n = 0; n < num; ++n) {
|
||||
buf = gst_buffer_list_get (buffer_list, n);
|
||||
|
||||
fail_unless (gst_buffer_map (buf, &info, GST_MAP_READ));
|
||||
|
||||
ptr = info.data;
|
||||
left = info.size;
|
||||
|
||||
while (left > 0) {
|
||||
fail_unless (GST_READ_UINT32_LE (ptr) == i);
|
||||
i++;
|
||||
ptr += sizeof (guint32);
|
||||
left -= sizeof (guint32);
|
||||
}
|
||||
gst_buffer_unmap (buf, &info);
|
||||
}
|
||||
gst_buffer_list_unref (buffer_list);
|
||||
}
|
||||
fail_unless (gst_adapter_available (adapter) == 0,
|
||||
"Data was left in the adapter");
|
||||
|
||||
g_object_unref (adapter);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_merge)
|
||||
{
|
||||
GstAdapter *adapter;
|
||||
|
@ -916,6 +963,7 @@ gst_adapter_suite (void)
|
|||
tcase_add_test (tc_chain, test_timestamp);
|
||||
tcase_add_test (tc_chain, test_scan);
|
||||
tcase_add_test (tc_chain, test_take_list);
|
||||
tcase_add_test (tc_chain, test_take_buffer_list);
|
||||
tcase_add_test (tc_chain, test_merge);
|
||||
tcase_add_test (tc_chain, test_take_buffer_fast);
|
||||
|
||||
|
|
Loading…
Reference in a new issue