tests: Add tests for RFC 8536 v3 parsing of time zones

This adds really basic validation that `GTimeZone` can successfully
parse a ‘slim’ format timezone file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2129
This commit is contained in:
Philip Withnall 2020-07-17 15:02:01 +01:00
parent e18a6a28db
commit 98a7d6e389
4 changed files with 34 additions and 0 deletions

View File

@ -2692,6 +2692,38 @@ test_new_offset (void)
}
}
static void
test_time_zone_parse_rfc8536 (void)
{
const gchar *test_files[] =
{
/* Generated with `zic -b slim`; see
* https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1533#note_842235 */
"Amsterdam-slim",
/* Generated with `zic -b fat` */
"Amsterdam-fat",
};
gsize i;
g_test_summary ("Test parsing time zone files in RFC 8536 version 3 format");
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2129");
for (i = 0; i < G_N_ELEMENTS (test_files); i++)
{
gchar *path = NULL;
GTimeZone *tz = NULL;
path = g_test_build_filename (G_TEST_DIST, "time-zones", test_files[i], NULL);
g_assert_true (g_path_is_absolute (path));
tz = g_time_zone_new (path);
g_assert_nonnull (tz);
/* UTC will be loaded as a fallback if parsing fails */
g_assert_cmpstr (g_time_zone_get_identifier (tz), !=, "UTC");
g_time_zone_unref (tz);
g_free (path);
}
}
gint
main (gint argc,
gchar *argv[])
@ -2761,6 +2793,7 @@ main (gint argc,
g_test_add_func ("/GTimeZone/floating-point", test_GDateTime_floating_point);
g_test_add_func ("/GTimeZone/identifier", test_identifier);
g_test_add_func ("/GTimeZone/new-offset", test_new_offset);
g_test_add_func ("/GTimeZone/parse-rfc8536", test_time_zone_parse_rfc8536);
return g_test_run ();
}

View File

@ -189,6 +189,7 @@ if installed_tests_enabled
)
install_subdir('bookmarks', install_dir : installed_tests_execdir)
install_subdir('markups', install_dir : installed_tests_execdir)
install_subdir('time-zones', install_dir : installed_tests_execdir)
endif
# Not entirely random of course, but at least it changes over time

Binary file not shown.

Binary file not shown.