check/Makefile.am: add gsttag

Original commit message from CVS:

* check/Makefile.am:
add gsttag
* check/gst/gsttag.c: (check_tags), (START_TEST), (gst_tag_suite),
(main):
move over from testsuite dir and clean up
* configure.ac:
* gst/gsttag.c:
* testsuite/Makefile.am:
* testsuite/tags/.cvsignore:
* testsuite/tags/Makefile.am:
* testsuite/tags/merge.c:
remove testsuite/tags
This commit is contained in:
Thomas Vander Stichele 2005-06-19 11:32:42 +00:00
parent 0944ac134b
commit d10d12dbcb
16 changed files with 519 additions and 435 deletions

View file

@ -1,3 +1,18 @@
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
* check/Makefile.am:
add gsttag
* check/gst/gsttag.c: (check_tags), (START_TEST), (gst_tag_suite),
(main):
move over from testsuite dir and clean up
* configure.ac:
* gst/gsttag.c:
* testsuite/Makefile.am:
* testsuite/tags/.cvsignore:
* testsuite/tags/Makefile.am:
* testsuite/tags/merge.c:
remove testsuite/tags
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/gst/gstreamer-sections.txt:

View file

@ -33,6 +33,7 @@ TESTS = $(top_builddir)/tools/gst-register \
gst/gstobject \
gst/gstpad \
gst/gstsystemclock \
gst/gsttag \
pipelines/simple_launch_lines \
pipelines/cleanup \
gst-libs/gdp

202
check/gst/gsttag.c Normal file
View file

@ -0,0 +1,202 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* parse1.c: Test various parsing stuff
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../gstcheck.h"
#include <string.h>
/* multiple artists are possible */
#define UTAG GST_TAG_ARTIST
#define UNFIXED1 "Britney Spears"
#define UNFIXED2 "Evanescence"
#define UNFIXED3 "AC/DC"
#define UNFIXED4 "The Prodigy"
/* license is fixed */
#define FTAG GST_TAG_LICENSE
#define FIXED1 "Lesser General Public License"
#define FIXED2 "Microsoft End User License Agreement"
#define FIXED3 "Mozilla Public License"
#define FIXED4 "Public Domain"
/* checks that a tag contains the given values and not more values */
static void
check_tags (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
guint i = 0;
va_start (args, value);
while (value != NULL) {
fail_unless (gst_tag_list_get_string_index (list, tag, i, &str));
fail_unless (strcmp (value, str) == 0);
g_free (str);
value = va_arg (args, gchar *);
i++;
}
fail_unless (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
#define NEW_LIST_FIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, \
FTAG, FIXED3, FTAG, FIXED4, NULL); \
} G_STMT_END;
#define NEW_LIST_UNFIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
} G_STMT_END;
#define NEW_LISTS_FIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, \
FTAG, FIXED2, NULL); \
if (list2) gst_tag_list_free (list2); \
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, \
FTAG, FIXED4, NULL); \
if (merge) gst_tag_list_free (merge); \
merge = gst_tag_list_merge (list, list2, mode); \
} G_STMT_END;
#define NEW_LISTS_UNFIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, \
UTAG, UNFIXED2, NULL); \
if (list2) gst_tag_list_free (list2); \
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3,\
UTAG, UNFIXED4, NULL); \
if (merge) gst_tag_list_free (merge); \
merge = gst_tag_list_merge (list, list2, mode); \
} G_STMT_END;
START_TEST (test_merge)
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
/* make sure the assumptions work */
fail_unless (gst_tag_is_fixed (FTAG));
fail_unless (!gst_tag_is_fixed (UTAG));
/* we check string here only */
fail_unless (gst_tag_get_type (FTAG) == G_TYPE_STRING);
fail_unless (gst_tag_get_type (UTAG) == G_TYPE_STRING);
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
check_tags (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
check_tags (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
check_tags (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
check_tags (list, UTAG, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (list, UTAG, NULL);
/* fixed */
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
check_tags (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
check_tags (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (list, FTAG, NULL);
/* check merging */
/* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
/* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (merge, FTAG, FIXED1, NULL);
}
END_TEST Suite *
gst_tag_suite (void)
{
Suite *s = suite_create ("GstTag");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_merge);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = gst_tag_suite ();
SRunner *sr = srunner_create (s);
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
return nf;
}

View file

@ -694,7 +694,6 @@ testsuite/plugin/Makefile
testsuite/refcounting/Makefile
testsuite/schedulers/Makefile
testsuite/states/Makefile
testsuite/tags/Makefile
testsuite/threads/Makefile
testsuite/trigger/Makefile
examples/Makefile

View file

@ -855,8 +855,8 @@ gst_event_tag_get_list (GstEvent * tag_event)
* Gets the value that is at the given index for the given tag in the given
* list.
*
* Returns: The GValue for the specified entry or NULL if the tag wasn't available
* or the tag doesn't have as many entries
* Returns: The GValue for the specified entry or NULL if the tag wasn't
* available or the tag doesn't have as many entries
*/
G_CONST_RETURN GValue *
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
@ -888,8 +888,9 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
* @list: list to get the tag from
* @tag: tag to read out
*
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
* Copies the contents for the given tag into the value,
* merging multiple values into one if multiple values are associated
* with the tag.
* You must g_value_unset() the value after use.
*
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
@ -944,7 +945,8 @@ gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
} \
\
gboolean \
gst_tag_list_get_ ## name ## _index (const GstTagList *list, const gchar *tag, \
gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
const gchar *tag, \
guint index, type *value) \
{ \
const GValue *v; \

View file

@ -855,8 +855,8 @@ gst_event_tag_get_list (GstEvent * tag_event)
* Gets the value that is at the given index for the given tag in the given
* list.
*
* Returns: The GValue for the specified entry or NULL if the tag wasn't available
* or the tag doesn't have as many entries
* Returns: The GValue for the specified entry or NULL if the tag wasn't
* available or the tag doesn't have as many entries
*/
G_CONST_RETURN GValue *
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
@ -888,8 +888,9 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
* @list: list to get the tag from
* @tag: tag to read out
*
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
* Copies the contents for the given tag into the value,
* merging multiple values into one if multiple values are associated
* with the tag.
* You must g_value_unset() the value after use.
*
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
@ -944,7 +945,8 @@ gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
} \
\
gboolean \
gst_tag_list_get_ ## name ## _index (const GstTagList *list, const gchar *tag, \
gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
const gchar *tag, \
guint index, type *value) \
{ \
const GValue *v; \

View file

@ -33,6 +33,7 @@ TESTS = $(top_builddir)/tools/gst-register \
gst/gstobject \
gst/gstpad \
gst/gstsystemclock \
gst/gsttag \
pipelines/simple_launch_lines \
pipelines/cleanup \
gst-libs/gdp

202
tests/check/gst/gsttag.c Normal file
View file

@ -0,0 +1,202 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* parse1.c: Test various parsing stuff
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../gstcheck.h"
#include <string.h>
/* multiple artists are possible */
#define UTAG GST_TAG_ARTIST
#define UNFIXED1 "Britney Spears"
#define UNFIXED2 "Evanescence"
#define UNFIXED3 "AC/DC"
#define UNFIXED4 "The Prodigy"
/* license is fixed */
#define FTAG GST_TAG_LICENSE
#define FIXED1 "Lesser General Public License"
#define FIXED2 "Microsoft End User License Agreement"
#define FIXED3 "Mozilla Public License"
#define FIXED4 "Public Domain"
/* checks that a tag contains the given values and not more values */
static void
check_tags (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
guint i = 0;
va_start (args, value);
while (value != NULL) {
fail_unless (gst_tag_list_get_string_index (list, tag, i, &str));
fail_unless (strcmp (value, str) == 0);
g_free (str);
value = va_arg (args, gchar *);
i++;
}
fail_unless (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
#define NEW_LIST_FIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, \
FTAG, FIXED3, FTAG, FIXED4, NULL); \
} G_STMT_END;
#define NEW_LIST_UNFIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
} G_STMT_END;
#define NEW_LISTS_FIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, \
FTAG, FIXED2, NULL); \
if (list2) gst_tag_list_free (list2); \
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, \
FTAG, FIXED4, NULL); \
if (merge) gst_tag_list_free (merge); \
merge = gst_tag_list_merge (list, list2, mode); \
} G_STMT_END;
#define NEW_LISTS_UNFIXED(mode) \
G_STMT_START { \
if (list) gst_tag_list_free (list); \
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, \
UTAG, UNFIXED2, NULL); \
if (list2) gst_tag_list_free (list2); \
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3,\
UTAG, UNFIXED4, NULL); \
if (merge) gst_tag_list_free (merge); \
merge = gst_tag_list_merge (list, list2, mode); \
} G_STMT_END;
START_TEST (test_merge)
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
/* make sure the assumptions work */
fail_unless (gst_tag_is_fixed (FTAG));
fail_unless (!gst_tag_is_fixed (UTAG));
/* we check string here only */
fail_unless (gst_tag_get_type (FTAG) == G_TYPE_STRING);
fail_unless (gst_tag_get_type (UTAG) == G_TYPE_STRING);
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
check_tags (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
check_tags (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
check_tags (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
check_tags (list, UTAG, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (list, UTAG, NULL);
/* fixed */
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
check_tags (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
check_tags (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
check_tags (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (list, FTAG, NULL);
/* check merging */
/* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
/* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (merge, FTAG, FIXED1, NULL);
}
END_TEST Suite *
gst_tag_suite (void)
{
Suite *s = suite_create ("GstTag");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_merge);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = gst_tag_suite ();
SRunner *sr = srunner_create (s);
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
return nf;
}

View file

@ -19,7 +19,7 @@ SUBDIRS = \
dlopen dynparams \
elements ghostpads indexers negotiation pad \
$(GST_PARSE_DIRS) \
plugin refcounting schedulers states tags threads trigger
plugin refcounting schedulers states threads trigger
DIST_SUBDIRS = \
bins bytestream caps cleanup clock \
@ -27,7 +27,7 @@ DIST_SUBDIRS = \
dlopen dynparams \
elements ghostpads indexers negotiation pad \
parse \
plugin refcounting schedulers states tags threads trigger
plugin refcounting schedulers states threads trigger
tests_pass = test_gst_init
tests_fail =

View file

@ -1,3 +0,0 @@
Makefile
Makefile.in
merge

View file

@ -1,5 +0,0 @@
include ../Rules
tests_pass = merge
tests_fail =
tests_ignore =

View file

@ -1,162 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* parse1.c: Test various parsing stuff
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gst/gst.h>
#include <string.h>
/* multiple artists are possible */
#define UTAG GST_TAG_ARTIST
#define UNFIXED1 "Britney Spears"
#define UNFIXED2 "Evanescene"
#define UNFIXED3 "AC/DC"
#define UNFIXED4 "The Prodigy"
/* license is fixed */
#define FTAG GST_TAG_LICENSE
#define FIXED1 "Lesser General Public License"
#define FIXED2 "Microsoft End User License Agreement"
#define FIXED3 "Mozilla Public License"
#define FIXED4 "Public Domain"
/* checks that a tag contains the given values and not more values */
static void
check (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
guint i = 0;
va_start (args, value);
while (value != NULL) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
g_assert (strcmp (value, str) == 0);
g_free (str);
value = va_arg (args, gchar *);
i++;
}
g_assert (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, FTAG, FIXED3, FTAG, FIXED4, NULL); \
}G_STMT_END
#define NEW_LIST_UNFIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL);\
}G_STMT_END
#define NEW_LISTS_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, FTAG, FIXED2, NULL); \
if (list2) gst_tag_list_free (list2);\
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, FTAG, FIXED4, NULL); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
#define NEW_LISTS_UNFIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, UTAG, UNFIXED2, NULL); \
if (list2) gst_tag_list_free (list2);\
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
gint
main (gint argc, gchar * argv[])
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
gst_init (&argc, &argv);
/* make sure the assumptions work */
g_assert (gst_tag_is_fixed (FTAG));
g_assert (!gst_tag_is_fixed (UTAG));
/* we check string here only */
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
check (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
check (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
check (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
check (list, UTAG, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, UTAG, NULL);
/* fixed */
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, FTAG, NULL);
/* check merging */
/* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
check (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
check (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
/* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, FTAG, FIXED1, NULL);
return 0;
}

View file

@ -19,7 +19,7 @@ SUBDIRS = \
dlopen dynparams \
elements ghostpads indexers negotiation pad \
$(GST_PARSE_DIRS) \
plugin refcounting schedulers states tags threads trigger
plugin refcounting schedulers states threads trigger
DIST_SUBDIRS = \
bins bytestream caps cleanup clock \
@ -27,7 +27,7 @@ DIST_SUBDIRS = \
dlopen dynparams \
elements ghostpads indexers negotiation pad \
parse \
plugin refcounting schedulers states tags threads trigger
plugin refcounting schedulers states threads trigger
tests_pass = test_gst_init
tests_fail =

View file

@ -1,3 +0,0 @@
Makefile
Makefile.in
merge

View file

@ -1,5 +0,0 @@
include ../Rules
tests_pass = merge
tests_fail =
tests_ignore =

View file

@ -1,162 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* parse1.c: Test various parsing stuff
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gst/gst.h>
#include <string.h>
/* multiple artists are possible */
#define UTAG GST_TAG_ARTIST
#define UNFIXED1 "Britney Spears"
#define UNFIXED2 "Evanescene"
#define UNFIXED3 "AC/DC"
#define UNFIXED4 "The Prodigy"
/* license is fixed */
#define FTAG GST_TAG_LICENSE
#define FIXED1 "Lesser General Public License"
#define FIXED2 "Microsoft End User License Agreement"
#define FIXED3 "Mozilla Public License"
#define FIXED4 "Public Domain"
/* checks that a tag contains the given values and not more values */
static void
check (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
guint i = 0;
va_start (args, value);
while (value != NULL) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
g_assert (strcmp (value, str) == 0);
g_free (str);
value = va_arg (args, gchar *);
i++;
}
g_assert (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, FTAG, FIXED3, FTAG, FIXED4, NULL); \
}G_STMT_END
#define NEW_LIST_UNFIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL);\
}G_STMT_END
#define NEW_LISTS_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, FTAG, FIXED2, NULL); \
if (list2) gst_tag_list_free (list2);\
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, FTAG, FIXED4, NULL); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
#define NEW_LISTS_UNFIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, UTAG, UNFIXED2, NULL); \
if (list2) gst_tag_list_free (list2);\
list2 = gst_tag_list_new (); \
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
gint
main (gint argc, gchar * argv[])
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
gst_init (&argc, &argv);
/* make sure the assumptions work */
g_assert (gst_tag_is_fixed (FTAG));
g_assert (!gst_tag_is_fixed (UTAG));
/* we check string here only */
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
check (list, UTAG, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
check (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
check (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
check (list, UTAG, UNFIXED1, NULL);
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, UTAG, NULL);
/* fixed */
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
check (list, FTAG, FIXED4, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, FTAG, NULL);
/* check merging */
/* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
check (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
check (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
/* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, FTAG, FIXED1, NULL);
return 0;
}