[glib] Improve GDate test coverage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve GDate test coverage
- Date: Wed, 1 Jan 2014 23:04:43 +0000 (UTC)
commit 3de604d438feb851c7517ab04a823d25bd1997ba
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 1 17:41:59 2014 -0500
Improve GDate test coverage
glib/tests/date.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/date.c b/glib/tests/date.c
index 786b80f..0d674c9 100644
--- a/glib/tests/date.c
+++ b/glib/tests/date.c
@@ -67,6 +67,8 @@ test_julian_constructor (void)
d2 = g_date_new_julian (5000);
g_assert_cmpint (g_date_get_julian (d1), ==, 4000);
g_assert_cmpint (g_date_days_between (d1, d2), ==, 1000);
+ g_assert_cmpint (g_date_get_year (d1), ==, 11);
+ g_assert_cmpint (g_date_get_day (d2), ==, 9);
g_date_free (d1);
g_date_free (d2);
}
@@ -130,6 +132,39 @@ test_parse (void)
g_assert_cmpint (g_date_get_day (d), ==, 10);
g_assert_cmpint (g_date_get_year (d), ==, 2000);
+ g_date_set_parse (d, "2001 10 1");
+ g_assert (g_date_valid (d));
+ g_assert_cmpint (g_date_get_month (d), ==, 10);
+ g_assert_cmpint (g_date_get_day (d), ==, 1);
+ g_assert_cmpint (g_date_get_year (d), ==, 2001);
+
+ g_date_set_parse (d, "2001 10");
+ g_assert (!g_date_valid (d));
+
+ g_date_set_parse (d, "2001 10 1 1");
+ g_assert (!g_date_valid (d));
+
+ g_date_set_parse (d, "March 1999");
+ g_assert (g_date_valid (d));
+ g_assert_cmpint (g_date_get_month (d), ==, 3);
+ g_assert_cmpint (g_date_get_day (d), ==, 1);
+ g_assert_cmpint (g_date_get_year (d), ==, 1999);
+
+ g_date_set_parse (d, "10 Sep 1087");
+ g_assert (g_date_valid (d));
+ g_assert_cmpint (g_date_get_month (d), ==, 9);
+ g_assert_cmpint (g_date_get_day (d), ==, 10);
+ g_assert_cmpint (g_date_get_year (d), ==, 1087);
+
+ g_date_set_parse (d, "19990301");
+ g_assert (g_date_valid (d));
+ g_assert_cmpint (g_date_get_month (d), ==, 3);
+ g_assert_cmpint (g_date_get_day (d), ==, 1);
+ g_assert_cmpint (g_date_get_year (d), ==, 1999);
+
+ g_date_set_parse (d, "20011320");
+ g_assert (!g_date_valid (d));
+
g_date_free (d);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]