Commit 0b75a928 authored by Philip Withnall's avatar Philip Withnall

Merge branch '2129-tz-slim-tests' into 'master'

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

See merge request !1578
parents 060fda09 98a7d6e3
Pipeline #198968 failed with stages
in 18 minutes and 48 seconds
......@@ -160,7 +160,7 @@ test_GDateTime_new_from_unix_overflow (void)
{
GDateTime *dt;
g_test_bug ("782089");
g_test_bug ("http://bugzilla.gnome.org/782089");
dt = g_date_time_new_from_unix_utc (G_MAXINT64);
g_assert_null (dt);
......@@ -174,7 +174,7 @@ test_GDateTime_invalid (void)
{
GDateTime *dt;
g_test_bug ("702674");
g_test_bug ("http://bugzilla.gnome.org/702674");
dt = g_date_time_new_utc (2013, -2147483647, 31, 17, 15, 48);
g_assert (dt == NULL);
......@@ -435,7 +435,7 @@ test_GDateTime_new_from_timeval_overflow (void)
GDateTime *dt;
GTimeVal tv;
g_test_bug ("782089");
g_test_bug ("http://bugzilla.gnome.org/782089");
tv.tv_sec = find_maximum_supported_tv_sec ();
tv.tv_usec = G_USEC_PER_SEC - 1;
......@@ -1772,7 +1772,7 @@ test_month_names (void)
{
gchar *oldlocale;
g_test_bug ("749206");
g_test_bug ("http://bugzilla.gnome.org/749206");
/* If running uninstalled (G_TEST_BUILDDIR is set), skip this test, since we
* need the translations to be installed. We can’t mess around with
......@@ -2114,7 +2114,7 @@ test_z (void)
GDateTime *dt;
gchar *p;
g_test_bug ("642935");
g_test_bug ("http://bugzilla.gnome.org/642935");
tz = g_time_zone_new ("-08:00");
dt = g_date_time_new (tz, 1, 1, 1, 0, 0, 0);
......@@ -2583,7 +2583,7 @@ test_GDateTime_floating_point (void)
GDateTime *dt;
GTimeZone *tz;
g_test_bug ("697715");
g_test_bug ("http://bugzilla.gnome.org/697715");
tz = g_time_zone_new ("-03:00");
g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "-03:00");
......@@ -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[])
......@@ -2701,7 +2733,6 @@ main (gint argc,
g_unsetenv ("LANGUAGE");
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
/* GDateTime Tests */
bind_textdomain_codeset ("glib20", "UTF-8");
......@@ -2762,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 ();
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment