+2008-05-14 Wim Taymans <wim.taymans@collabora.co.uk>
+
+ * gst/parse/grammar.y:
+ Remove unneeded value unset.
+
+ * tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
+ Add unit test for de/serialization of caps.
+
2008-05-13 Sebastian Dröge <slomo@circular-chaos.org>
* plugins/elements/gstfakesink.c:
GST_END_TEST;
+GST_START_TEST (test_serialize_deserialize_caps)
+{
+ GValue value = { 0 }, value2 = {
+ 0};
+ GstCaps *caps, *caps2;
+ gchar *serialized;
+
+ caps = gst_caps_new_simple ("test/caps",
+ "foo", G_TYPE_INT, 10, "bar", G_TYPE_STRING, "test", NULL);
+ fail_if (GST_CAPS_REFCOUNT_VALUE (caps) != 1);
+
+ /* and assign caps to gvalue */
+ g_value_init (&value, GST_TYPE_CAPS);
+ g_value_take_boxed (&value, caps);
+ fail_if (GST_CAPS_REFCOUNT_VALUE (caps) != 1);
+
+ /* now serialize it */
+ serialized = gst_value_serialize (&value);
+ GST_DEBUG ("serialized caps to %s", serialized);
+ fail_unless (serialized != NULL);
+
+ /* refcount should not change */
+ fail_if (GST_CAPS_REFCOUNT_VALUE (caps) != 1);
+
+ /* now deserialize again */
+ g_value_init (&value2, GST_TYPE_CAPS);
+ gst_value_deserialize (&value2, serialized);
+
+ caps2 = g_value_get_boxed (&value2);
+ fail_if (GST_CAPS_REFCOUNT_VALUE (caps2) != 1);
+
+ /* they should be equal */
+ fail_unless (gst_caps_is_equal (caps, caps2));
+
+ /* cleanup */
+ g_value_unset (&value);
+ g_value_unset (&value2);
+ g_free (serialized);
+}
+
+GST_END_TEST;
+
static Suite *
gst_value_suite (void)
{
tcase_add_test (tc_chain, test_value_subtract_fraction_range);
tcase_add_test (tc_chain, test_date);
tcase_add_test (tc_chain, test_fraction_range);
+ tcase_add_test (tc_chain, test_serialize_deserialize_caps);
return s;
}