+2006-05-10 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * gst/gstevent.c: (_gst_event_initialize):
+ * gst/gstformat.c: (_gst_format_initialize):
+ make sure some essential types used by events are registered
+ as part of gst_init()
+ * gst/gstvalue.c: (gst_value_serialize_flags):
+ if no flags are set, serialize them to a value that represents NONE
+ so that deserializing them works
+ * tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
+ add tests for serialization and deserialization of flags
+
2006-05-10 Wim Taymans <wim@fluendo.com>
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_collect),
GST_END_TEST;
+GST_START_TEST (test_serialize_flags)
+{
+ GValue value = { 0 };
+ gchar *string;
+ GstSeekFlags flags[] = {
+ 0,
+ GST_SEEK_FLAG_NONE,
+ GST_SEEK_FLAG_FLUSH,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ };
+ const char *results[] = {
+ "GST_SEEK_FLAG_NONE",
+ "GST_SEEK_FLAG_NONE",
+ "GST_SEEK_FLAG_FLUSH",
+ "GST_SEEK_FLAG_FLUSH+GST_SEEK_FLAG_ACCURATE",
+ };
+ int i;
+
+ g_value_init (&value, GST_TYPE_SEEK_FLAGS);
+
+ for (i = 0; i < G_N_ELEMENTS (flags); ++i) {
+ g_value_set_flags (&value, flags[i]);
+ string = gst_value_serialize (&value);
+ fail_if (string == NULL, "could not serialize flags %d", i);
+ fail_unless (strcmp (string, results[i]) == 0,
+ "resulting value is %s, not %s, for flags #%d", string, results[i], i);
+ }
+}
+
+GST_END_TEST;
+
+
+GST_START_TEST (test_deserialize_flags)
+{
+ GValue value = { 0 };
+ const char *strings[] = {
+ "",
+ "0",
+ "GST_SEEK_FLAG_NONE",
+ "GST_SEEK_FLAG_FLUSH",
+ "GST_SEEK_FLAG_FLUSH+GST_SEEK_FLAG_ACCURATE",
+ };
+ GstSeekFlags results[] = {
+ GST_SEEK_FLAG_NONE,
+ GST_SEEK_FLAG_NONE,
+ GST_SEEK_FLAG_NONE,
+ GST_SEEK_FLAG_FLUSH,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ };
+ int i;
+
+ g_value_init (&value, GST_TYPE_SEEK_FLAGS);
+
+ for (i = 0; i < G_N_ELEMENTS (strings); ++i) {
+ fail_unless (gst_value_deserialize (&value, strings[i]),
+ "could not deserialize %s (%d)", strings[i], i);
+ fail_unless (g_value_get_flags (&value) == results[i],
+ "resulting value is %d, not %d, for string %s (%d)",
+ g_value_get_flags (&value), results[i], strings[i], i);
+ }
+}
+
+GST_END_TEST;
GST_START_TEST (test_string)
{
tcase_add_test (tc_chain, test_deserialize_guint_failures);
tcase_add_test (tc_chain, test_deserialize_gint64);
tcase_add_test (tc_chain, test_deserialize_gstfraction);
+ tcase_add_test (tc_chain, test_serialize_flags);
+ tcase_add_test (tc_chain, test_deserialize_flags);
tcase_add_test (tc_chain, test_string);
tcase_add_test (tc_chain, test_deserialize_string);
tcase_add_test (tc_chain, test_value_compare);