iterator: Add unit test for the single iterator

This commit is contained in:
Sebastian Dröge 2009-09-01 10:21:31 +02:00
parent 690f980690
commit 3a5cceeb6b

View file

@ -167,6 +167,37 @@ GST_START_TEST (test_fold)
GST_END_TEST;
GST_START_TEST (test_single)
{
GstIterator *it;
GstStructure *s = gst_structure_new ("test", NULL);
GstStructure *i;
it = gst_iterator_new_single (GST_TYPE_STRUCTURE, s,
(GstCopyFunction) gst_structure_copy, (GFreeFunc) gst_structure_free);
fail_unless (gst_iterator_next (it, (gpointer *) & i) == GST_ITERATOR_OK);
fail_unless (strcmp (gst_structure_get_name (s),
gst_structure_get_name (i)) == 0);
gst_structure_free (i);
i = NULL;
fail_unless (gst_iterator_next (it, (gpointer *) & i) == GST_ITERATOR_DONE);
fail_unless (i == NULL);
gst_iterator_free (it);
gst_structure_free (s);
it = gst_iterator_new_single (GST_TYPE_STRUCTURE, NULL,
(GstCopyFunction) gst_structure_copy, (GFreeFunc) gst_structure_free);
fail_unless (gst_iterator_next (it, (gpointer *) & i) == GST_ITERATOR_DONE);
fail_unless (i == NULL);
gst_iterator_free (it);
}
GST_END_TEST;
static Suite *
gst_iterator_suite (void)
{
@ -179,6 +210,7 @@ gst_iterator_suite (void)
tcase_add_test (tc_chain, test_manual_iteration);
tcase_add_test (tc_chain, test_resync);
tcase_add_test (tc_chain, test_fold);
tcase_add_test (tc_chain, test_single);
return s;
}