mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 13:26:36 +00:00
tests: one more test for gst_queue_array_drop_element()
https://bugzilla.gnome.org/show_bug.cgi?id=692691 Conflicts: tests/check/libs/queuearray.c
This commit is contained in:
parent
5a7c1b56dc
commit
bc397c780c
1 changed files with 49 additions and 0 deletions
|
@ -199,6 +199,54 @@ GST_START_TEST (test_array_grow_end)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static int
|
||||
compare_pointer_value (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return (int) ((guintptr) a - (guintptr) b);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_array_drop2)
|
||||
{
|
||||
#define NUM_QA_ELEMENTS 674
|
||||
gboolean in_array[NUM_QA_ELEMENTS] = { FALSE, };
|
||||
GstQueueArray *array;
|
||||
guint i, j, count, idx;
|
||||
|
||||
array = gst_queue_array_new (10);
|
||||
|
||||
for (i = 0; i < NUM_QA_ELEMENTS; i++) {
|
||||
gpointer element = GUINT_TO_POINTER (i);
|
||||
|
||||
if (g_random_boolean ()) {
|
||||
gst_queue_array_push_tail (array, element);
|
||||
in_array[i] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
|
||||
count += in_array[j] ? 1 : 0;
|
||||
fail_unless_equals_int (gst_queue_array_get_length (array), count);
|
||||
|
||||
while (gst_queue_array_get_length (array) > 0) {
|
||||
for (i = 0; i < NUM_QA_ELEMENTS; i++) {
|
||||
if (g_random_boolean () && g_random_boolean () && in_array[i]) {
|
||||
idx = gst_queue_array_find (array, compare_pointer_value,
|
||||
GUINT_TO_POINTER (i));
|
||||
gst_queue_array_drop_element (array, idx);
|
||||
in_array[i] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
|
||||
count += in_array[j] ? 1 : 0;
|
||||
fail_unless_equals_int (gst_queue_array_get_length (array), count);
|
||||
}
|
||||
|
||||
gst_queue_array_free (array);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_queue_array_suite (void)
|
||||
{
|
||||
|
@ -212,6 +260,7 @@ gst_queue_array_suite (void)
|
|||
tcase_add_test (tc_chain, test_array_grow_multiple);
|
||||
tcase_add_test (tc_chain, test_array_grow_middle);
|
||||
tcase_add_test (tc_chain, test_array_grow_end);
|
||||
tcase_add_test (tc_chain, test_array_drop2);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue