summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2005-11-22 12:35:42 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2005-11-22 12:35:42 +0000
commit32538f9ed2315c2eb304212bca0809ec258efa06 (patch)
treeb9ec20255d4ceb7447755313a6669e0034fafd04
parent861fb1c1155fc3ee388ab5f28a28db20bd3a6789 (diff)
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.
-rw-r--r--ChangeLog11
-rw-r--r--check/gst/capslist.h3
-rw-r--r--check/gst/gststructure.c32
-rw-r--r--gst/gststructure.c3
-rw-r--r--tests/check/gst/capslist.h3
-rw-r--r--tests/check/gst/gststructure.c32
6 files changed, 83 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e10c0febd..4090c2980 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/check/gst/capslist.h b/check/gst/capslist.h
index 6e7beda95..b8458e64e 100644
--- a/check/gst/capslist.h
+++ b/check/gst/capslist.h
@@ -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",
diff --git a/check/gst/gststructure.c b/check/gst/gststructure.c
index dc0137b65..60342be1e 100644
--- a/check/gst/gststructure.c
+++ b/check/gst/gststructure.c
@@ -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;
}
diff --git a/gst/gststructure.c b/gst/gststructure.c
index 5141caba8..f09d81751 100644
--- a/gst/gststructure.c
+++ b/gst/gststructure.c
@@ -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++) {
diff --git a/tests/check/gst/capslist.h b/tests/check/gst/capslist.h
index 6e7beda95..b8458e64e 100644
--- a/tests/check/gst/capslist.h
+++ b/tests/check/gst/capslist.h
@@ -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",
diff --git a/tests/check/gst/gststructure.c b/tests/check/gst/gststructure.c
index dc0137b65..60342be1e 100644
--- a/tests/check/gst/gststructure.c
+++ b/tests/check/gst/gststructure.c
@@ -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;
}