mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
tests: turn toc check macros into proper functions
So we can see the line number of the check that fails.
This commit is contained in:
parent
94e0e06efa
commit
c427d8caa8
2 changed files with 146 additions and 137 deletions
|
@ -47,78 +47,81 @@
|
||||||
|
|
||||||
#define TEST_UID "129537542"
|
#define TEST_UID "129537542"
|
||||||
|
|
||||||
#define CHECK_TOC_ENTRY(entry_c,type_c,uid_c) \
|
static void
|
||||||
{ \
|
CHECK_TOC_ENTRY (GstTocEntry * entry_c, GstTocEntryType type_c,
|
||||||
GstTagList *tags; \
|
const gchar * uid_c)
|
||||||
gchar *tag_c; \
|
{
|
||||||
\
|
GstTagList *tags;
|
||||||
fail_unless_equals_string (gst_toc_entry_get_uid (entry_c), uid_c); \
|
gchar *tag_c;
|
||||||
fail_unless (gst_toc_entry_get_entry_type (entry_c) == type_c); \
|
|
||||||
\
|
fail_unless_equals_string (gst_toc_entry_get_uid (entry_c), uid_c);
|
||||||
tags = gst_toc_entry_get_tags (entry_c); \
|
fail_unless (gst_toc_entry_get_entry_type (entry_c) == type_c);
|
||||||
fail_unless (tags != NULL); \
|
|
||||||
fail_unless (gst_tag_list_get_string (tags, \
|
tags = gst_toc_entry_get_tags (entry_c);
|
||||||
GST_TAG_TITLE, &tag_c)); \
|
fail_unless (tags != NULL);
|
||||||
fail_unless_equals_string (tag_c, ENTRY_TAG); \
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag_c));
|
||||||
g_free (tag_c); \
|
fail_unless_equals_string (tag_c, ENTRY_TAG);
|
||||||
|
g_free (tag_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_TOC(toc_t) \
|
static void
|
||||||
{ \
|
CHECK_TOC (GstToc * toc_t)
|
||||||
GstTocEntry *entry_t, *subentry_t; \
|
{
|
||||||
GstTagList *tags; \
|
GstTocEntry *entry_t, *subentry_t;
|
||||||
GList *entries, *subentries, *subsubentries; \
|
GstTagList *tags;
|
||||||
gchar *tag_t; \
|
GList *entries, *subentries, *subsubentries;
|
||||||
\
|
gchar *tag_t;
|
||||||
/* dump TOC */ \
|
|
||||||
gst_toc_dump (toc_t); \
|
/* dump TOC */
|
||||||
\
|
gst_toc_dump (toc_t);
|
||||||
/* check TOC */ \
|
|
||||||
tags = gst_toc_get_tags (toc_t); \
|
/* check TOC */
|
||||||
fail_unless (tags != NULL); \
|
tags = gst_toc_get_tags (toc_t);
|
||||||
fail_unless (gst_tag_list_get_string (tags, \
|
fail_unless (tags != NULL);
|
||||||
GST_TAG_TITLE, &tag_t)); \
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag_t));
|
||||||
fail_unless_equals_string (tag_t, TOC_TAG); \
|
fail_unless_equals_string (tag_t, TOC_TAG);
|
||||||
g_free (tag_t); \
|
g_free (tag_t);
|
||||||
\
|
|
||||||
entries = gst_toc_get_entries (toc_t); \
|
entries = gst_toc_get_entries (toc_t);
|
||||||
fail_unless_equals_int (g_list_length (entries), 2); \
|
fail_unless_equals_int (g_list_length (entries), 2);
|
||||||
/* check edition1 */ \
|
/* check edition1 */
|
||||||
entry_t = g_list_nth_data (entries, 0); \
|
entry_t = g_list_nth_data (entries, 0);
|
||||||
fail_if (entry_t == NULL); \
|
fail_if (entry_t == NULL);
|
||||||
subentries = gst_toc_entry_get_sub_entries (entry_t); \
|
subentries = gst_toc_entry_get_sub_entries (entry_t);
|
||||||
fail_unless_equals_int (g_list_length (subentries), 2); \
|
fail_unless_equals_int (g_list_length (subentries), 2);
|
||||||
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED1); \
|
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED1);
|
||||||
/* check chapter1 */ \
|
/* check chapter1 */
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
fail_if (subentry_t == NULL); \
|
fail_if (subentry_t == NULL);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH1); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH1);
|
||||||
/* check chapter2 */ \
|
/* check chapter2 */
|
||||||
subentry_t = g_list_nth_data (subentries, 1); \
|
subentry_t = g_list_nth_data (subentries, 1);
|
||||||
fail_if (subentry_t == NULL); \
|
fail_if (subentry_t == NULL);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH2); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH2);
|
||||||
/* check edition2 */ \
|
/* check edition2 */
|
||||||
entry_t = g_list_nth_data (entries, 1); \
|
entry_t = g_list_nth_data (entries, 1);
|
||||||
fail_if (entry_t == NULL); \
|
fail_if (entry_t == NULL);
|
||||||
subentries = gst_toc_entry_get_sub_entries (entry_t); \
|
subentries = gst_toc_entry_get_sub_entries (entry_t);
|
||||||
fail_unless_equals_int (g_list_length (subentries), 1); \
|
fail_unless_equals_int (g_list_length (subentries), 1);
|
||||||
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED2); \
|
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED2);
|
||||||
/* check chapter3 */ \
|
/* check chapter3 */
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
fail_if (subentry_t == NULL); \
|
fail_if (subentry_t == NULL);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 1); \
|
fail_unless_equals_int (g_list_length (subsubentries), 1);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH3); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH3);
|
||||||
/* check subchapter1 */ \
|
/* check subchapter1 */
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
fail_if (subentry_t == NULL); \
|
fail_if (subentry_t == NULL);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
GST_ERROR ("%s", gst_toc_entry_get_uid (subentry_t));
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_SUB1); \
|
GST_ERROR ("%p", subsubentries);
|
||||||
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_SUB1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This whole test is a bit pointless now that we just stuff a ref of
|
/* This whole test is a bit pointless now that we just stuff a ref of
|
||||||
|
|
|
@ -35,75 +35,81 @@
|
||||||
#define ENTRY_TAG "EntryTag"
|
#define ENTRY_TAG "EntryTag"
|
||||||
#define TOC_TAG "TocTag"
|
#define TOC_TAG "TocTag"
|
||||||
|
|
||||||
#define CHECK_TOC_ENTRY(entry_c,type_c,uid_c) \
|
static void
|
||||||
{ \
|
CHECK_TOC_ENTRY (GstTocEntry * entry_c, GstTocEntryType type_c,
|
||||||
GstTagList *tags; \
|
const gchar * uid_c)
|
||||||
gchar *tag_c; \
|
{
|
||||||
\
|
GstTagList *tags;
|
||||||
fail_unless_equals_string (gst_toc_entry_get_uid (entry_c), uid_c); \
|
gchar *tag_c;
|
||||||
fail_unless (gst_toc_entry_get_entry_type (entry_c) == type_c); \
|
|
||||||
\
|
fail_unless_equals_string (gst_toc_entry_get_uid (entry_c), uid_c);
|
||||||
tags = gst_toc_entry_get_tags (entry_c); \
|
fail_unless (gst_toc_entry_get_entry_type (entry_c) == type_c);
|
||||||
fail_unless (tags != NULL); \
|
|
||||||
fail_unless (gst_tag_list_get_string (tags, \
|
tags = gst_toc_entry_get_tags (entry_c);
|
||||||
GST_TAG_TITLE, &tag_c)); \
|
fail_unless (tags != NULL);
|
||||||
fail_unless_equals_string (tag_c, ENTRY_TAG); \
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag_c));
|
||||||
g_free (tag_c); \
|
fail_unless_equals_string (tag_c, ENTRY_TAG);
|
||||||
|
g_free (tag_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_TOC(toc_t) \
|
static void
|
||||||
{ \
|
CHECK_TOC (GstToc * toc_t)
|
||||||
GstTocEntry *entry_t, *subentry_t; \
|
{
|
||||||
GstTagList *tags; \
|
GstTocEntry *entry_t, *subentry_t;
|
||||||
GList *entries, *subentries, *subsubentries; \
|
GstTagList *tags;
|
||||||
gchar *tag_t; \
|
GList *entries, *subentries, *subsubentries;
|
||||||
\
|
gchar *tag_t;
|
||||||
/* check TOC */ \
|
|
||||||
tags = gst_toc_get_tags (toc_t); \
|
/* dump TOC */
|
||||||
fail_unless (tags != NULL); \
|
gst_toc_dump (toc_t);
|
||||||
fail_unless (gst_tag_list_get_string (tags, \
|
|
||||||
GST_TAG_TITLE, &tag_t)); \
|
/* check TOC */
|
||||||
fail_unless_equals_string (tag_t, TOC_TAG); \
|
tags = gst_toc_get_tags (toc_t);
|
||||||
g_free (tag_t); \
|
fail_unless (tags != NULL);
|
||||||
\
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag_t));
|
||||||
entries = gst_toc_get_entries (toc_t); \
|
fail_unless_equals_string (tag_t, TOC_TAG);
|
||||||
fail_unless_equals_int (g_list_length (entries), 2); \
|
g_free (tag_t);
|
||||||
/* check edition1 */ \
|
|
||||||
entry_t = g_list_nth_data (entries, 0); \
|
entries = gst_toc_get_entries (toc_t);
|
||||||
fail_if (entry_t == NULL); \
|
fail_unless_equals_int (g_list_length (entries), 2);
|
||||||
subentries = gst_toc_entry_get_sub_entries (entry_t); \
|
/* check edition1 */
|
||||||
fail_unless_equals_int (g_list_length (subentries), 2); \
|
entry_t = g_list_nth_data (entries, 0);
|
||||||
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED1); \
|
fail_if (entry_t == NULL);
|
||||||
/* check chapter1 */ \
|
subentries = gst_toc_entry_get_sub_entries (entry_t);
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
fail_unless_equals_int (g_list_length (subentries), 2);
|
||||||
fail_if (subentry_t == NULL); \
|
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED1);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
/* check chapter1 */
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH1); \
|
fail_if (subentry_t == NULL);
|
||||||
/* check chapter2 */ \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
subentry_t = g_list_nth_data (subentries, 1); \
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
fail_if (subentry_t == NULL); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH1);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
/* check chapter2 */
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
subentry_t = g_list_nth_data (subentries, 1);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH2); \
|
fail_if (subentry_t == NULL);
|
||||||
/* check edition2 */ \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
entry_t = g_list_nth_data (entries, 1); \
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
fail_if (entry_t == NULL); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH2);
|
||||||
subentries = gst_toc_entry_get_sub_entries (entry_t); \
|
/* check edition2 */
|
||||||
fail_unless_equals_int (g_list_length (subentries), 1); \
|
entry_t = g_list_nth_data (entries, 1);
|
||||||
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED2); \
|
fail_if (entry_t == NULL);
|
||||||
/* check chapter3 */ \
|
subentries = gst_toc_entry_get_sub_entries (entry_t);
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
fail_unless_equals_int (g_list_length (subentries), 1);
|
||||||
fail_if (subentry_t == NULL); \
|
CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED2);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
/* check chapter3 */
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 1); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH3); \
|
fail_if (subentry_t == NULL);
|
||||||
/* check subchapter1 */ \
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
subentry_t = g_list_nth_data (subentries, 0); \
|
fail_unless_equals_int (g_list_length (subsubentries), 1);
|
||||||
fail_if (subentry_t == NULL); \
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH3);
|
||||||
subsubentries = gst_toc_entry_get_sub_entries (subentry_t); \
|
/* check subchapter1 */
|
||||||
fail_unless_equals_int (g_list_length (subsubentries), 0); \
|
subentry_t = g_list_nth_data (subentries, 0);
|
||||||
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_SUB1); \
|
fail_if (subentry_t == NULL);
|
||||||
|
GST_ERROR ("%s", gst_toc_entry_get_uid (subentry_t));
|
||||||
|
subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
|
||||||
|
GST_ERROR ("%p", subsubentries);
|
||||||
|
fail_unless_equals_int (g_list_length (subsubentries), 0);
|
||||||
|
CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_SUB1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* some minimal GstTocSetter object */
|
/* some minimal GstTocSetter object */
|
||||||
|
|
Loading…
Reference in a new issue