From: Tim-Philipp Müller Date: Tue, 12 Jun 2012 23:21:32 +0000 (+0100) Subject: tests: add some basic unit tests for partial date time fields X-Git-Tag: RELEASE-0.11.93~341 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b45a44ef27ec8f9bb77a8f495c67ba1a371d05a8;p=platform%2Fupstream%2Fgstreamer.git tests: add some basic unit tests for partial date time fields --- diff --git a/tests/check/gst/gstdatetime.c b/tests/check/gst/gstdatetime.c index 10f1c60..3dff97c 100644 --- a/tests/check/gst/gstdatetime.c +++ b/tests/check/gst/gstdatetime.c @@ -283,6 +283,77 @@ GST_START_TEST (test_GstDateTime_get_utc_offset) GST_END_TEST; +GST_START_TEST (test_GstDateTime_partial_fields) +{ + GstDateTime *dt; + + ASSERT_CRITICAL (gst_date_time_new (0.0, -1, -1, -1, -1, -1, -1)); + ASSERT_CRITICAL (gst_date_time_new (0.0, 2012, 7, 18, 9, -1, -1)); + + dt = gst_date_time_new (0.0, 2012, -1, -1, -1, -1, -1); + fail_unless (gst_date_time_has_year (dt)); + fail_unless_equals_int (gst_date_time_get_year (dt), 2012); + fail_if (gst_date_time_has_month (dt)); + ASSERT_CRITICAL (gst_date_time_get_month (dt)); + fail_if (gst_date_time_has_day (dt)); + ASSERT_CRITICAL (gst_date_time_get_day (dt)); + fail_if (gst_date_time_has_time (dt)); + ASSERT_CRITICAL (gst_date_time_get_hour (dt)); + ASSERT_CRITICAL (gst_date_time_get_minute (dt)); + fail_if (gst_date_time_has_second (dt)); + ASSERT_CRITICAL (gst_date_time_get_second (dt)); + gst_date_time_unref (dt); + + dt = gst_date_time_new (0.0, 2012, 7, -1, -1, -1, -1); + fail_unless (gst_date_time_has_year (dt)); + fail_unless_equals_int (gst_date_time_get_year (dt), 2012); + fail_unless (gst_date_time_has_month (dt)); + fail_unless_equals_int (gst_date_time_get_month (dt), 7); + fail_if (gst_date_time_has_day (dt)); + ASSERT_CRITICAL (gst_date_time_get_day (dt)); + fail_if (gst_date_time_has_time (dt)); + ASSERT_CRITICAL (gst_date_time_get_hour (dt)); + ASSERT_CRITICAL (gst_date_time_get_minute (dt)); + fail_if (gst_date_time_has_second (dt)); + ASSERT_CRITICAL (gst_date_time_get_second (dt)); + gst_date_time_unref (dt); + + dt = gst_date_time_new (0.0, 2012, 7, 1, -1, -1, -1); + fail_unless (gst_date_time_has_year (dt)); + fail_unless (gst_date_time_has_month (dt)); + fail_unless_equals_int (gst_date_time_get_month (dt), 7); + fail_unless (gst_date_time_has_day (dt)); + fail_unless_equals_int (gst_date_time_get_day (dt), 1); + fail_if (gst_date_time_has_time (dt)); + fail_if (gst_date_time_has_second (dt)); + gst_date_time_unref (dt); + + dt = gst_date_time_new (0.0, 2012, 7, 1, 18, 20, -1); + fail_unless (gst_date_time_has_year (dt)); + fail_unless_equals_int (gst_date_time_get_year (dt), 2012); + fail_unless (gst_date_time_has_month (dt)); + fail_unless_equals_int (gst_date_time_get_month (dt), 7); + fail_unless (gst_date_time_has_day (dt)); + fail_unless_equals_int (gst_date_time_get_day (dt), 1); + fail_unless (gst_date_time_has_time (dt)); + fail_unless_equals_int (gst_date_time_get_hour (dt), 18); + fail_unless_equals_int (gst_date_time_get_minute (dt), 20); + fail_if (gst_date_time_has_second (dt)); + gst_date_time_unref (dt); + + dt = gst_date_time_new (0.0, 2012, 7, 1, 18, 20, 25.0443); + fail_unless (gst_date_time_has_year (dt)); + fail_unless (gst_date_time_has_month (dt)); + fail_unless (gst_date_time_has_day (dt)); + fail_unless (gst_date_time_has_time (dt)); + fail_unless (gst_date_time_has_second (dt)); + fail_unless_equals_int (gst_date_time_get_second (dt), 25); + /* fail_unless_equals_int (gst_date_time_get_microsecond (dt), 443); */ + gst_date_time_unref (dt); +} + +GST_END_TEST; + static Suite * gst_date_time_suite (void) { @@ -301,8 +372,9 @@ gst_date_time_suite (void) tcase_add_test (tc_chain, test_GstDateTime_new_full); tcase_add_test (tc_chain, test_GstDateTime_now); tcase_add_test (tc_chain, test_GstDateTime_utc_now); + tcase_add_test (tc_chain, test_GstDateTime_partial_fields); return s; } -GST_CHECK_MAIN (gst_date_time); +GST_CHECK_MAIN (gst_date_time)