Files
glib/glib/tests
Simon McVittie 472dee3909 gdatetime test: don't assume that time stands still
If we call time(NULL), then do something (however trivial), then call
g_date_time_new_now_utc(), they do not necessarily share a seconds
value. Let's say the gmtime call takes 2ms. time(NULL) could
return xx:xx:23 when the time is actually xx:xx:23.999999, resulting
in the g_date_time_new_now_utc() happening at xx:xx:24.000001. This is
unlikely, but did happen to me in a parallel build:

GLib:ERROR:.../glib/tests/gdatetime.c:674:test_GDateTime_now_utc: assertion failed (tm.tm_sec == g_date_time_get_second (dt)): (23 == 24)

A similar argument applies to the rollover from xx:23:59.999999 to
xx:24:00, so comparing seconds with a 1s "fuzz" or a >= comparison
is not sufficient; and so on into higher-order fields.

I haven't seen the other tests that use _now() fail in the same way,
but they could.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=749080
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 17:48:02 +01:00
..
2015-03-18 14:28:14 -07:00
2012-11-15 14:19:06 -05:00
2014-01-31 14:31:55 +01:00
2014-01-01 17:59:22 -05:00
2015-02-23 10:40:40 -05:00
2010-07-10 23:56:45 -04:00
2012-10-16 21:21:25 -04:00
2014-01-31 14:31:55 +01:00
2014-01-31 14:31:55 +01:00
2014-10-02 14:41:01 -04:00
2010-07-05 23:43:47 -04:00
2012-04-08 10:24:52 -04:00
2011-02-13 23:49:19 -05:00
2014-04-16 16:20:46 +01:00
2011-10-08 19:02:06 -04:00
2014-01-31 14:31:55 +01:00
2013-11-23 00:39:07 -05:00
2010-07-07 22:03:02 -04:00
2014-01-01 17:59:21 -05:00
2014-01-01 17:59:22 -05:00
2013-11-11 22:39:57 +08:00
2014-01-31 14:31:55 +01:00
2011-10-13 01:00:57 -04:00
2011-01-27 23:07:53 -05:00
2014-01-31 14:31:55 +01:00
2014-01-01 17:59:22 -05:00
2011-06-03 23:38:46 -04:00
2012-05-13 01:14:17 -04:00
2012-05-13 01:14:17 -04:00
2014-01-31 14:31:55 +01:00
2014-01-31 14:31:55 +01:00
2014-02-02 09:35:17 +00:00
2011-10-03 23:55:02 -04:00
2014-01-31 14:31:55 +01:00
2014-11-25 12:51:36 +00:00
2014-01-01 22:39:32 -05:00
2014-01-31 14:31:55 +01:00
2014-06-28 12:49:38 -04:00
2014-01-01 17:59:21 -05:00
2014-01-31 14:31:55 +01:00
2014-01-31 14:31:55 +01:00
2014-01-31 14:31:55 +01:00
2014-01-31 14:31:55 +01:00