From 35ae6c747288c78df47cc8769456ee2d8cd571b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 7 Oct 2006 18:41:19 +0000 Subject: [PATCH] gst/gsttaglist.*: Minor fixes to GST_IS_TAG_LIST and gst_is_tag_list(). Original commit message from CVS: * gst/gsttaglist.c: (gst_is_tag_list): * gst/gsttaglist.h: Minor fixes to GST_IS_TAG_LIST and gst_is_tag_list(). * tests/check/gst/gsttag.c: (GST_START_TEST), (gst_tag_suite): Small test for the above. --- ChangeLog | 9 +++++++++ gst/gsttaglist.c | 4 +++- gst/gsttaglist.h | 2 +- tests/check/gst/gsttag.c | 21 ++++++++++++++++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4617362b0..150e0ad62c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-10-07 Tim-Philipp Müller + + * gst/gsttaglist.c: (gst_is_tag_list): + * gst/gsttaglist.h: + Minor fixes to GST_IS_TAG_LIST and gst_is_tag_list(). + + * tests/check/gst/gsttag.c: (GST_START_TEST), (gst_tag_suite): + Small test for the above. + 2006-10-07 Tim-Philipp Müller * gst/gsttaglist.h: diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 47b20f4bbb..29a54bd9b2 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -479,9 +479,11 @@ gst_tag_list_new (void) gboolean gst_is_tag_list (gconstpointer p) { + GstStructure *s = (GstStructure *) p; + g_return_val_if_fail (p != NULL, FALSE); - return ((GstStructure *) p)->name == gst_tag_list_quark; + return (GST_IS_STRUCTURE (s) && s->name == gst_tag_list_quark); } typedef struct { diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index cd25451853..62508b7a58 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -82,7 +82,7 @@ typedef enum { */ typedef GstStructure GstTagList; #define GST_TAG_LIST(x) ((GstTagList *) (x)) -#define GST_IS_TAG_LIST(x) (gst_is_tag_list (GST_TAG_LIST (x))) +#define GST_IS_TAG_LIST(x) ((x) != NULL && gst_is_tag_list (GST_TAG_LIST (x))) #define GST_TYPE_TAG_LIST (gst_tag_list_get_type ()) /** diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index efc4e23bbe..e0b1be36f3 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -215,7 +215,25 @@ GST_START_TEST (test_date_tags) GST_END_TEST; -Suite * +GST_START_TEST (test_type) +{ + GstTagList *taglist; + + taglist = gst_tag_list_new (); + fail_unless (GST_IS_TAG_LIST (taglist)); + fail_unless (gst_is_tag_list (taglist)); + gst_tag_list_free (taglist); + + /* this isn't okay */ + ASSERT_CRITICAL (fail_if (gst_is_tag_list (NULL))); + + /* this however should be fine */ + fail_if (GST_IS_TAG_LIST (NULL)); +} + +GST_END_TEST; + +static Suite * gst_tag_suite (void) { Suite *s = suite_create ("GstTag"); @@ -224,6 +242,7 @@ gst_tag_suite (void) suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_merge); tcase_add_test (tc_chain, test_date_tags); + tcase_add_test (tc_chain, test_type); return s; }