gstreamer/testsuite/caps/subtract.c
Benjamin Otte 614b4d1627 gst/gstcaps.c: check for ANY caps before appending/unioning
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_append), (gst_caps_union):
check for ANY caps before appending/unioning
* gst/gstcaps.c: (gst_caps_is_subset),
(gst_caps_is_equal), (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract):
* gst/gstcaps.h:
add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to
the API. deprecate gst_caps_is_equal_fixed
* gst/gstpad.c: (gst_pad_try_set_caps):
* gst/gstqueue.c: (gst_queue_link):
s/gst_caps_is_equal_fixed/gst_caps_is_equal/
* gst/gststructure.c: (gst_structure_get_name_id):
* gst/gststructure.h:
add function gst_structure_get_name_id
* gst/gstvalue.c: (gst_value_subtract_int_int_range),
(gst_value_create_new_range), (gst_value_subtract_int_range_int),
(gst_value_subtract_int_range_int_range),
(gst_value_subtract_double_double_range),
(gst_value_subtract_double_range_double),
(gst_value_subtract_double_range_double_range),
(gst_value_subtract_from_list), (gst_value_subtract_list),
(gst_value_can_intersect), (gst_value_subtract),
(gst_value_can_subtract), (gst_value_register_subtract_func),
(_gst_value_initialize):
* gst/gstvalue.h:
add support for subtracting values from each other. Note that
subtracting means subtracting as in set theory. Required for caps
stuff above.
* testsuite/caps/.cvsignore:
* testsuite/caps/Makefile.am:
* testsuite/caps/erathostenes.c: (erathostenes), (main):
* testsuite/caps/sets.c: (check_caps), (main):
* testsuite/caps/subtract.c: (check_caps), (main):
add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00

63 lines
2.1 KiB
C

/*
* Copyright (C) 2004 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* 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>
static void
check_caps (const gchar * set, const gchar * subset)
{
GstCaps *one, *two, *test, *test2;
g_print (" A = %s\n", set);
one = gst_caps_from_string (set);
g_print (" B = %s\n", subset);
two = gst_caps_from_string (subset);
/* basics */
test = gst_caps_subtract (one, one);
g_assert (gst_caps_is_empty (test));
gst_caps_free (test);
test = gst_caps_subtract (two, two);
g_assert (gst_caps_is_empty (test));
gst_caps_free (test);
test = gst_caps_subtract (two, one);
g_assert (gst_caps_is_empty (test));
gst_caps_free (test);
/* now the nice part */
test = gst_caps_subtract (one, two);
g_assert (!gst_caps_is_empty (test));
g_print (" A - B = %s\n", gst_caps_to_string (test));
test2 = gst_caps_union (test, two);
g_print ("A - B + B = %s\n", gst_caps_to_string (test2));
gst_caps_free (test);
test = gst_caps_subtract (test2, one);
g_assert (gst_caps_is_empty (test));
gst_caps_free (test);
}
gint
main (gint argc, gchar ** argv)
{
gst_init (&argc, &argv);
check_caps ("some/mime, _int = [ 1, 2 ], list = { \"A\", \"B\", \"C\" }",
"some/mime, _int = 1, list = \"A\"");
check_caps ("some/mime, _double = (double) 1.0; other/mime, _int = { 1, 2 }",
"some/mime, _double = (double) 1.0");
return 0;
}