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.
This commit is contained in:
Chun-wei Fan 2019-06-13 16:53:45 +08:00
parent f24444c585
commit 5d54727180

View File

@ -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);
}