From 4a3dde96e70bd1748a4273c5e7ab85f64b082c17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 12 Jun 2010 08:04:47 +0200 Subject: [PATCH] value: Add test for deserializing fourccs --- tests/check/gst/gstvalue.c | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index 7f47c97496..4615b391c4 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -66,6 +66,50 @@ GST_START_TEST (test_serialize_fourcc) GST_END_TEST; +GST_START_TEST (test_deserialize_fourcc) +{ + int i; + + guint32 fourccs[] = { + GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), + GST_MAKE_FOURCC ('Y', '8', '0', '0'), + GST_MAKE_FOURCC ('Y', '8', ' ', ' '), + GST_MAKE_FOURCC ('Y', '8', ' ', ' '), + GST_MAKE_FOURCC ('Y', '8', ' ', ' '), + GST_MAKE_FOURCC ('Y', '1', '6', ' '), + GST_MAKE_FOURCC ('Y', 'U', 'Y', '_'), + GST_MAKE_FOURCC ('Y', 'U', 'Y', '#'), + }; + gint fourccs_size = sizeof (fourccs) / sizeof (fourccs[0]); + const gchar *fourcc_strings[] = { + "YUY2", + "Y800", + "Y8 ", + "Y8 ", + "Y8", + "Y16 ", + "0x5f595559", /* Ascii values of YUY_ */ + "0x23595559", /* Ascii values of YUY# */ + }; + gint fourcc_strings_size = + sizeof (fourcc_strings) / sizeof (fourcc_strings[0]); + + fail_unless (fourccs_size == fourcc_strings_size); + + for (i = 0; i < fourccs_size; ++i) { + GValue value = { 0 }; + + g_value_init (&value, GST_TYPE_FOURCC); + + fail_unless (gst_value_deserialize (&value, fourcc_strings[i])); + fail_unless_equals_int (gst_value_get_fourcc (&value), fourccs[i]); + + g_value_unset (&value); + } +} + +GST_END_TEST; + GST_START_TEST (test_deserialize_buffer) { GValue value = { 0 }; @@ -1805,6 +1849,7 @@ gst_value_suite (void) suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_serialize_fourcc); + tcase_add_test (tc_chain, test_deserialize_fourcc); tcase_add_test (tc_chain, test_deserialize_buffer); tcase_add_test (tc_chain, test_serialize_buffer); tcase_add_test (tc_chain, test_deserialize_gint); -- 2.34.1