From 1709fe625f0bf2f9393a9ba6de547e53070c566b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 22 Sep 2005 15:38:12 +0000 Subject: [PATCH] check/gst/gstvalue.c: Add simplistic test suite for GST_TYPE_DATE serialisation and deserialisation. Original commit message from CVS: * check/gst/gstvalue.c: (test_date), (gst_value_suite): Add simplistic test suite for GST_TYPE_DATE serialisation and deserialisation. --- ChangeLog | 6 +++++ check/gst/gstvalue.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ tests/check/gst/gstvalue.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/ChangeLog b/ChangeLog index 45dc69e..db54d3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-09-22 Tim-Philipp Müller + * check/gst/gstvalue.c: (test_date), (gst_value_suite): + Add simplistic test suite for GST_TYPE_DATE serialisation and + deserialisation. + +2005-09-22 Tim-Philipp Müller + * docs/gst/gstreamer-sections.txt: * gst/gststructure.c: (gst_structure_set_valist), (gst_structure_get_date): diff --git a/check/gst/gstvalue.c b/check/gst/gstvalue.c index b492d12..37c5a3c 100644 --- a/check/gst/gstvalue.c +++ b/check/gst/gstvalue.c @@ -919,6 +919,61 @@ GST_START_TEST (test_value_subtract_double) GST_END_TEST; +GST_START_TEST (test_date) +{ + GstStructure *s; + GDate *date, *date2; + gchar *str; + + date = g_date_new_dmy (22, 9, 2005); + + s = gst_structure_new ("media/x-type", "SOME_DATE_TAG", GST_TYPE_DATE, + date, NULL); + + fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", + GST_TYPE_DATE)); + fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date2)); + fail_unless (date2 != NULL); + fail_unless (g_date_valid (date2)); + fail_unless (g_date_compare (date, date2) == 0); + + g_date_free (date); + date = NULL; + + str = gst_structure_to_string (s); + gst_structure_free (s); + s = NULL; + + fail_unless (g_str_equal (str, + "media/x-type, SOME_DATE_TAG=(GstDate)2005-09-22")); + + s = gst_structure_from_string (str, NULL); + g_free (str); + str = NULL; + + fail_unless (s != NULL); + fail_unless (gst_structure_has_name (s, "media/x-type")); + fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", + GST_TYPE_DATE)); + fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date)); + fail_unless (date != NULL); + fail_unless (g_date_valid (date)); + fail_unless (g_date_get_day (date) == 22); + fail_unless (g_date_get_month (date) == 9); + fail_unless (g_date_get_year (date) == 2005); + + str = gst_structure_to_string (s); + gst_structure_free (s); + s = NULL; + + fail_unless (g_str_equal (str, + "media/x-type, SOME_DATE_TAG=(GstDate)2005-09-22")); + g_free (str); + str = NULL; +} + +GST_END_TEST; + Suite * gst_value_suite (void) { @@ -938,6 +993,7 @@ gst_value_suite (void) tcase_add_test (tc_chain, test_value_intersect); tcase_add_test (tc_chain, test_value_subtract_int); tcase_add_test (tc_chain, test_value_subtract_double); + tcase_add_test (tc_chain, test_date); return s; } diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index b492d12..37c5a3c 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -919,6 +919,61 @@ GST_START_TEST (test_value_subtract_double) GST_END_TEST; +GST_START_TEST (test_date) +{ + GstStructure *s; + GDate *date, *date2; + gchar *str; + + date = g_date_new_dmy (22, 9, 2005); + + s = gst_structure_new ("media/x-type", "SOME_DATE_TAG", GST_TYPE_DATE, + date, NULL); + + fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", + GST_TYPE_DATE)); + fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date2)); + fail_unless (date2 != NULL); + fail_unless (g_date_valid (date2)); + fail_unless (g_date_compare (date, date2) == 0); + + g_date_free (date); + date = NULL; + + str = gst_structure_to_string (s); + gst_structure_free (s); + s = NULL; + + fail_unless (g_str_equal (str, + "media/x-type, SOME_DATE_TAG=(GstDate)2005-09-22")); + + s = gst_structure_from_string (str, NULL); + g_free (str); + str = NULL; + + fail_unless (s != NULL); + fail_unless (gst_structure_has_name (s, "media/x-type")); + fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", + GST_TYPE_DATE)); + fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date)); + fail_unless (date != NULL); + fail_unless (g_date_valid (date)); + fail_unless (g_date_get_day (date) == 22); + fail_unless (g_date_get_month (date) == 9); + fail_unless (g_date_get_year (date) == 2005); + + str = gst_structure_to_string (s); + gst_structure_free (s); + s = NULL; + + fail_unless (g_str_equal (str, + "media/x-type, SOME_DATE_TAG=(GstDate)2005-09-22")); + g_free (str); + str = NULL; +} + +GST_END_TEST; + Suite * gst_value_suite (void) { @@ -938,6 +993,7 @@ gst_value_suite (void) tcase_add_test (tc_chain, test_value_intersect); tcase_add_test (tc_chain, test_value_subtract_int); tcase_add_test (tc_chain, test_value_subtract_double); + tcase_add_test (tc_chain, test_date); return s; } -- 2.7.4