From 5d54727180b46765c30a51e7ebbb2a743f4120c2 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 13 Jun 2019 16:53:45 +0800 Subject: [PATCH] glib/tests/gdatetime.c: Fix TZ envvar test on Windows Windows does not recognize the "America/Recife" as a valid timezone identifier, so setting the TZ envvar to that will result in "UTC" to be returned on Windows. Instead, set TZ to be the Windows equivilant "SA Eastern Standard Time", and see whether that is indeed our identifier when we create the GTimeZone using that. --- glib/tests/gdatetime.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c index ff2f89a61..32dd69283 100644 --- a/glib/tests/gdatetime.c +++ b/glib/tests/gdatetime.c @@ -2416,6 +2416,12 @@ test_identifier (void) GTimeZone *tz; gchar *old_tz = g_strdup (g_getenv ("TZ")); +#ifdef G_OS_WIN32 + const char *recife_tz = "SA Eastern Standard Time"; +#else + const char *recife_tz = "America/Recife"; +#endif + tz = g_time_zone_new ("UTC"); g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "UTC"); g_time_zone_unref (tz); @@ -2445,10 +2451,10 @@ test_identifier (void) g_time_zone_unref (tz); /* Local timezone tests. */ - if (g_setenv ("TZ", "America/Recife", TRUE)) + if (g_setenv ("TZ", recife_tz, TRUE)) { tz = g_time_zone_new_local (); - g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "America/Recife"); + g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, recife_tz); g_time_zone_unref (tz); }