[glib/wip/carlosg/gdatetime-before-y1000: 17/17] glib: Add tests for far away GDateTimes




commit 16fcd0814eee8b967fe61af87ab53fefd778b99e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Mar 20 13:26:50 2022 +0100

    glib: Add tests for far away GDateTimes
    
    Poke near the limits (years 9 and 9990) to ensure these also
    result in a correct ISO8601 format.

 glib/tests/gdatetime.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 2853b1174..141263b66 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -2321,6 +2321,22 @@ test_format_iso8601 (void)
   g_free (p);
   g_date_time_unref (dt);
   g_time_zone_unref (tz);
+
+  tz = g_time_zone_new_utc ();
+  dt = g_date_time_new (tz, 9, 1, 2, 3, 4, 55);
+  p = g_date_time_format_iso8601 (dt);
+  g_assert_cmpstr (p, ==, "0009-01-02T03:04:55Z");
+  g_free (p);
+  g_date_time_unref (dt);
+  g_time_zone_unref (tz);
+
+  tz = g_time_zone_new_utc ();
+  dt = g_date_time_new (tz, 9990, 1, 2, 3, 4, 55.000001);
+  p = g_date_time_format_iso8601 (dt);
+  g_assert_cmpstr (p, ==, "9990-01-02T03:04:55.000001Z");
+  g_free (p);
+  g_date_time_unref (dt);
+  g_time_zone_unref (tz);
 }
 
 typedef struct


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]