check/gst/capslist.h: Comment test cases

Original commit message from CVS:

* check/gst/capslist.h:
Comment test cases
* check/gst/gststructure.c: (GST_START_TEST),
(gst_structure_suite):
Test automatic value type detection in gst_structure_from_string.
* gst/gststructure.c: (gst_structure_parse_value):
Add fraction as a type we try and guess automatically in
caps/structure strings.
This commit is contained in:
Jan Schmidt 2005-11-22 12:35:42 +00:00
parent 861fb1c115
commit 32538f9ed2
6 changed files with 83 additions and 1 deletions

View file

@ -1,3 +1,14 @@
2005-11-22 Jan Schmidt <thaytan@mad.scientist.com>
* check/gst/capslist.h:
Comment test cases
* check/gst/gststructure.c: (GST_START_TEST),
(gst_structure_suite):
Test automatic value type detection in gst_structure_from_string.
* gst/gststructure.c: (gst_structure_parse_value):
Add fraction as a type we try and guess automatically in
caps/structure strings.
2005-11-22 Andy Wingo <wingo@pobox.com>
patch by: Torsten Schoenfeld <kaffeetisch gmx de>

View file

@ -15,11 +15,14 @@ static const gchar *caps_list[] = {
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0x000000FF, framerate = (double) [ 0, max ]",
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
"video/x-raw-rgb,\\ bpp=(int)32",
/* Test fraction type */
"test/gst-fraction, fraction = (fraction) 1/8",
"test/gst-fraction, fraction = (fraction) MIN",
"test/gst-fraction, fraction = (fraction) MAX",
/* Test fraction range */
"test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]",
"test/gst-fraction-range, fraction = (fraction) [ MIN, MAX ]",
/* Test lists of fractions and fraction ranges */
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }",
"ANY",

View file

@ -72,6 +72,37 @@ GST_START_TEST (test_from_string_int)
GST_END_TEST;
/* Test type conversions from string */
GST_START_TEST (test_from_string)
{
GstStructure *structure;
const gchar *s;
const GValue *val;
s = "test-string,value=1";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_INT (val));
gst_structure_free (structure);
s = "test-string,value=1.0";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_DOUBLE (val));
gst_structure_free (structure);
s = "test-string,value=1/1";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (GST_VALUE_HOLDS_FRACTION (val));
gst_structure_free (structure);
}
GST_END_TEST;
Suite *
gst_value_suite (void)
{
@ -110,6 +141,7 @@ gst_structure_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_from_string_int);
tcase_add_test (tc_chain, test_from_string);
tcase_add_test (tc_chain, test_structure_new);
return s;
}

View file

@ -1633,7 +1633,8 @@ gst_structure_parse_value (gchar * str,
c = *value_end;
*value_end = 0;
if (type == G_TYPE_INVALID) {
GType try_types[] = { G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING };
GType try_types[] =
{ G_TYPE_INT, G_TYPE_DOUBLE, GST_TYPE_FRACTION, G_TYPE_STRING };
int i;
for (i = 0; i < 3; i++) {

View file

@ -15,11 +15,14 @@ static const gchar *caps_list[] = {
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0x000000FF, framerate = (double) [ 0, max ]",
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
"video/x-raw-rgb,\\ bpp=(int)32",
/* Test fraction type */
"test/gst-fraction, fraction = (fraction) 1/8",
"test/gst-fraction, fraction = (fraction) MIN",
"test/gst-fraction, fraction = (fraction) MAX",
/* Test fraction range */
"test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]",
"test/gst-fraction-range, fraction = (fraction) [ MIN, MAX ]",
/* Test lists of fractions and fraction ranges */
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }",
"ANY",

View file

@ -72,6 +72,37 @@ GST_START_TEST (test_from_string_int)
GST_END_TEST;
/* Test type conversions from string */
GST_START_TEST (test_from_string)
{
GstStructure *structure;
const gchar *s;
const GValue *val;
s = "test-string,value=1";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_INT (val));
gst_structure_free (structure);
s = "test-string,value=1.0";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_DOUBLE (val));
gst_structure_free (structure);
s = "test-string,value=1/1";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (GST_VALUE_HOLDS_FRACTION (val));
gst_structure_free (structure);
}
GST_END_TEST;
Suite *
gst_value_suite (void)
{
@ -110,6 +141,7 @@ gst_structure_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_from_string_int);
tcase_add_test (tc_chain, test_from_string);
tcase_add_test (tc_chain, test_structure_new);
return s;
}