mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
tests: gstdatetime: move gst_date_time_new* and time() calls closer
While extremelly rare, time and gst_date_time_new_* will have diff values and potentially trigger an assertion. Thus move the calls as closely together as possible to mitigate this.
This commit is contained in:
parent
37edc474e3
commit
20ee2db955
1 changed files with 2 additions and 2 deletions
|
@ -44,12 +44,12 @@ GST_START_TEST (test_GstDateTime_now)
|
||||||
|
|
||||||
memset (&tm, 0, sizeof (tm));
|
memset (&tm, 0, sizeof (tm));
|
||||||
t = time (NULL);
|
t = time (NULL);
|
||||||
|
dt = gst_date_time_new_now_local_time ();
|
||||||
#ifdef HAVE_LOCALTIME_R
|
#ifdef HAVE_LOCALTIME_R
|
||||||
localtime_r (&t, &tm);
|
localtime_r (&t, &tm);
|
||||||
#else
|
#else
|
||||||
memcpy (&tm, localtime (&t), sizeof (struct tm));
|
memcpy (&tm, localtime (&t), sizeof (struct tm));
|
||||||
#endif
|
#endif
|
||||||
dt = gst_date_time_new_now_local_time ();
|
|
||||||
assert_equals_int (gst_date_time_get_year (dt), 1900 + tm.tm_year);
|
assert_equals_int (gst_date_time_get_year (dt), 1900 + tm.tm_year);
|
||||||
assert_equals_int (gst_date_time_get_month (dt), 1 + tm.tm_mon);
|
assert_equals_int (gst_date_time_get_month (dt), 1 + tm.tm_mon);
|
||||||
assert_equals_int (gst_date_time_get_day (dt), tm.tm_mday);
|
assert_equals_int (gst_date_time_get_day (dt), tm.tm_mday);
|
||||||
|
@ -248,12 +248,12 @@ GST_START_TEST (test_GstDateTime_utc_now)
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
t = time (NULL);
|
t = time (NULL);
|
||||||
|
dt = gst_date_time_new_now_utc ();
|
||||||
#ifdef HAVE_GMTIME_R
|
#ifdef HAVE_GMTIME_R
|
||||||
gmtime_r (&t, &tm);
|
gmtime_r (&t, &tm);
|
||||||
#else
|
#else
|
||||||
memcpy (&tm, gmtime (&t), sizeof (struct tm));
|
memcpy (&tm, gmtime (&t), sizeof (struct tm));
|
||||||
#endif
|
#endif
|
||||||
dt = gst_date_time_new_now_utc ();
|
|
||||||
assert_equals_int (tm.tm_year + 1900, gst_date_time_get_year (dt));
|
assert_equals_int (tm.tm_year + 1900, gst_date_time_get_year (dt));
|
||||||
assert_equals_int (tm.tm_mon + 1, gst_date_time_get_month (dt));
|
assert_equals_int (tm.tm_mon + 1, gst_date_time_get_month (dt));
|
||||||
assert_equals_int (tm.tm_mday, gst_date_time_get_day (dt));
|
assert_equals_int (tm.tm_mday, gst_date_time_get_day (dt));
|
||||||
|
|
Loading…
Reference in a new issue