[glib] Add a test for g_date_time_new_from_timeval_utc
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add a test for g_date_time_new_from_timeval_utc
- Date: Sun, 9 Oct 2011 03:49:49 +0000 (UTC)
commit d9e9239a4659c972279955e77d0351e664613e70
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 5 23:00:09 2011 -0400
Add a test for g_date_time_new_from_timeval_utc
glib/tests/gdatetime.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 9cfc2f1..da1ee1e 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -326,6 +326,31 @@ test_GDateTime_new_from_timeval (void)
}
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
test_GDateTime_to_unix (void)
{
GDateTime *dt;
@@ -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_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_utc", test_GDateTime_new_from_timeval_utc);
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/printf", test_GDateTime_printf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]