Add a test for g_date_time_new_from_timeval_utc

This commit is contained in:
Matthias Clasen 2011-10-05 23:00:09 -04:00
parent c739a5df14
commit d9e9239a46

View File

@ -325,6 +325,31 @@ test_GDateTime_new_from_timeval (void)
g_date_time_unref (dt); g_date_time_unref (dt);
} }
static void
test_GDateTime_new_from_timeval_utc (void)
{
GDateTime *dt;
GTimeVal tv, tv2;
g_get_current_time (&tv);
dt = g_date_time_new_from_timeval_utc (&tv);
if (g_test_verbose ())
g_print ("\nDT%04d-%02d-%02dT%02d:%02d:%02d%s\n",
g_date_time_get_year (dt),
g_date_time_get_month (dt),
g_date_time_get_day_of_month (dt),
g_date_time_get_hour (dt),
g_date_time_get_minute (dt),
g_date_time_get_second (dt),
g_date_time_get_timezone_abbreviation (dt));
g_date_time_to_timeval (dt, &tv2);
g_assert_cmpint (tv.tv_sec, ==, tv2.tv_sec);
g_assert_cmpint (tv.tv_usec, ==, tv2.tv_usec);
g_date_time_unref (dt);
}
static void static void
test_GDateTime_to_unix (void) test_GDateTime_to_unix (void)
{ {
@ -1167,6 +1192,7 @@ main (gint argc,
g_test_add_func ("/GDateTime/new_from_unix", test_GDateTime_new_from_unix); g_test_add_func ("/GDateTime/new_from_unix", test_GDateTime_new_from_unix);
g_test_add_func ("/GDateTime/new_from_unix_utc", test_GDateTime_new_from_unix_utc); g_test_add_func ("/GDateTime/new_from_unix_utc", test_GDateTime_new_from_unix_utc);
g_test_add_func ("/GDateTime/new_from_timeval", test_GDateTime_new_from_timeval); g_test_add_func ("/GDateTime/new_from_timeval", test_GDateTime_new_from_timeval);
g_test_add_func ("/GDateTime/new_from_timeval_utc", test_GDateTime_new_from_timeval_utc);
g_test_add_func ("/GDateTime/new_full", test_GDateTime_new_full); g_test_add_func ("/GDateTime/new_full", test_GDateTime_new_full);
g_test_add_func ("/GDateTime/now", test_GDateTime_now); g_test_add_func ("/GDateTime/now", test_GDateTime_now);
g_test_add_func ("/GDateTime/printf", test_GDateTime_printf); g_test_add_func ("/GDateTime/printf", test_GDateTime_printf);