tests: Fix GDateTime tests on FreeBSD

`g_time_zone_new_identifier()` returns NULL in the FreeBSD test setup,
presumably because `TZ` isn’t set.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #553
This commit is contained in:
Philip Withnall 2020-11-23 15:49:02 +00:00
parent 72360eb8bd
commit 2237db78f1

View File

@ -2849,8 +2849,13 @@ test_time_zone_caching (void)
/* Check the default timezone, local and UTC. These are cached internally in
* GLib, so should persist even after the last third party reference is
* dropped. */
* dropped.
*
* The default timezone could be NULL on some platforms (FreeBSD) if
* `/etc/localtime` is not set correctly. */
tz1 = g_time_zone_new_identifier (NULL);
if (tz1 != NULL)
{
g_assert_nonnull (tz1);
g_time_zone_unref (tz1);
tz2 = g_time_zone_new_identifier (NULL);
@ -2858,6 +2863,7 @@ test_time_zone_caching (void)
g_time_zone_unref (tz2);
g_assert_true (tz1 == tz2);
}
tz1 = g_time_zone_new_utc ();
g_time_zone_unref (tz1);