mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-30 20:33:08 +02:00
tests: Explicitly set TZ=UTC for g_time_val_from_iso8601() testing
Some of the test vectors don’t specify a timezone, so the local one is used; the comparisons to the expected results (which are in UTC) then fail. See discussion in https://gitlab.gnome.org/GNOME/glib/merge_requests/225. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
cce309aebb
commit
b1bfebc61c
@ -134,6 +134,7 @@ typedef struct {
|
|||||||
static void
|
static void
|
||||||
test_timeval_from_iso8601 (void)
|
test_timeval_from_iso8601 (void)
|
||||||
{
|
{
|
||||||
|
gchar *old_tz = g_strdup (g_getenv ("TZ"));
|
||||||
TimeValParseTest tests[] = {
|
TimeValParseTest tests[] = {
|
||||||
{ TRUE, "1990-11-01T10:21:17Z", { 657454877, 0 } },
|
{ TRUE, "1990-11-01T10:21:17Z", { 657454877, 0 } },
|
||||||
{ TRUE, "19901101T102117Z", { 657454877, 0 } },
|
{ TRUE, "19901101T102117Z", { 657454877, 0 } },
|
||||||
@ -190,7 +191,12 @@ test_timeval_from_iso8601 (void)
|
|||||||
gboolean success;
|
gboolean success;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_unsetenv ("TZ");
|
/* Always run in UTC so the comparisons of parsed values are valid. */
|
||||||
|
if (!g_setenv ("TZ", "UTC", TRUE))
|
||||||
|
{
|
||||||
|
g_test_skip ("Failed to set TZ=UTC");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (tests); i++)
|
for (i = 0; i < G_N_ELEMENTS (tests); i++)
|
||||||
{
|
{
|
||||||
@ -204,6 +210,13 @@ test_timeval_from_iso8601 (void)
|
|||||||
g_assert_cmpint (out.tv_usec, ==, tests[i].val.tv_usec);
|
g_assert_cmpint (out.tv_usec, ==, tests[i].val.tv_usec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (old_tz != NULL)
|
||||||
|
g_assert_true (g_setenv ("TZ", old_tz, TRUE));
|
||||||
|
else
|
||||||
|
g_unsetenv ("TZ");
|
||||||
|
|
||||||
|
g_free (old_tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user