mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-05 18:40:58 +01:00
Merge branch '2129-tz-slim-tests' into 'master'
tests: Add tests for RFC 8536 v3 parsing of time zones See merge request GNOME/glib!1578
This commit is contained in:
commit
0b75a92823
@ -160,7 +160,7 @@ test_GDateTime_new_from_unix_overflow (void)
|
|||||||
{
|
{
|
||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
|
|
||||||
g_test_bug ("782089");
|
g_test_bug ("http://bugzilla.gnome.org/782089");
|
||||||
|
|
||||||
dt = g_date_time_new_from_unix_utc (G_MAXINT64);
|
dt = g_date_time_new_from_unix_utc (G_MAXINT64);
|
||||||
g_assert_null (dt);
|
g_assert_null (dt);
|
||||||
@ -174,7 +174,7 @@ test_GDateTime_invalid (void)
|
|||||||
{
|
{
|
||||||
GDateTime *dt;
|
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);
|
dt = g_date_time_new_utc (2013, -2147483647, 31, 17, 15, 48);
|
||||||
g_assert (dt == NULL);
|
g_assert (dt == NULL);
|
||||||
@ -435,7 +435,7 @@ test_GDateTime_new_from_timeval_overflow (void)
|
|||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
GTimeVal tv;
|
GTimeVal tv;
|
||||||
|
|
||||||
g_test_bug ("782089");
|
g_test_bug ("http://bugzilla.gnome.org/782089");
|
||||||
|
|
||||||
tv.tv_sec = find_maximum_supported_tv_sec ();
|
tv.tv_sec = find_maximum_supported_tv_sec ();
|
||||||
tv.tv_usec = G_USEC_PER_SEC - 1;
|
tv.tv_usec = G_USEC_PER_SEC - 1;
|
||||||
@ -1772,7 +1772,7 @@ test_month_names (void)
|
|||||||
{
|
{
|
||||||
gchar *oldlocale;
|
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
|
/* 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
|
* need the translations to be installed. We can’t mess around with
|
||||||
@ -2114,7 +2114,7 @@ test_z (void)
|
|||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
gchar *p;
|
gchar *p;
|
||||||
|
|
||||||
g_test_bug ("642935");
|
g_test_bug ("http://bugzilla.gnome.org/642935");
|
||||||
|
|
||||||
tz = g_time_zone_new ("-08:00");
|
tz = g_time_zone_new ("-08:00");
|
||||||
dt = g_date_time_new (tz, 1, 1, 1, 0, 0, 0);
|
dt = g_date_time_new (tz, 1, 1, 1, 0, 0, 0);
|
||||||
@ -2583,7 +2583,7 @@ test_GDateTime_floating_point (void)
|
|||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
GTimeZone *tz;
|
GTimeZone *tz;
|
||||||
|
|
||||||
g_test_bug ("697715");
|
g_test_bug ("http://bugzilla.gnome.org/697715");
|
||||||
|
|
||||||
tz = g_time_zone_new ("-03:00");
|
tz = g_time_zone_new ("-03:00");
|
||||||
g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "-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
|
gint
|
||||||
main (gint argc,
|
main (gint argc,
|
||||||
gchar *argv[])
|
gchar *argv[])
|
||||||
@ -2701,7 +2733,6 @@ main (gint argc,
|
|||||||
g_unsetenv ("LANGUAGE");
|
g_unsetenv ("LANGUAGE");
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
|
||||||
|
|
||||||
/* GDateTime Tests */
|
/* GDateTime Tests */
|
||||||
bind_textdomain_codeset ("glib20", "UTF-8");
|
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/floating-point", test_GDateTime_floating_point);
|
||||||
g_test_add_func ("/GTimeZone/identifier", test_identifier);
|
g_test_add_func ("/GTimeZone/identifier", test_identifier);
|
||||||
g_test_add_func ("/GTimeZone/new-offset", test_new_offset);
|
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 ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@ -189,6 +189,7 @@ if installed_tests_enabled
|
|||||||
)
|
)
|
||||||
install_subdir('bookmarks', install_dir : installed_tests_execdir)
|
install_subdir('bookmarks', install_dir : installed_tests_execdir)
|
||||||
install_subdir('markups', install_dir : installed_tests_execdir)
|
install_subdir('markups', install_dir : installed_tests_execdir)
|
||||||
|
install_subdir('time-zones', install_dir : installed_tests_execdir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Not entirely random of course, but at least it changes over time
|
# Not entirely random of course, but at least it changes over time
|
||||||
|
BIN
glib/tests/time-zones/Amsterdam-fat
Normal file
BIN
glib/tests/time-zones/Amsterdam-fat
Normal file
Binary file not shown.
BIN
glib/tests/time-zones/Amsterdam-slim
Normal file
BIN
glib/tests/time-zones/Amsterdam-slim
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user