From f7c66423a41a57b0ec43cddf0fc9de949ab3fed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 25 Jan 2022 02:03:38 +0400 Subject: [PATCH] glib/tests: set Polish ThreadLocale on win32 to fix a test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes /date/month_substring Bail out! GLib:ERROR:../glib/tests/date.c:1090:test_month_substring: 'g_date_valid (&date)' should be TRUE Signed-off-by: Marc-André Lureau --- glib/tests/date.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/glib/tests/date.c b/glib/tests/date.c index 5a799dc05..2fd9e8caf 100644 --- a/glib/tests/date.c +++ b/glib/tests/date.c @@ -1084,6 +1084,9 @@ static void test_month_substring (void) { GDate date; +#ifdef G_OS_WIN32 + LCID old_lcid; +#endif g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=793550"); @@ -1093,6 +1096,13 @@ test_month_substring (void) return; } +#ifdef G_OS_WIN32 + /* after the crt, set also the win32 thread locale: */ + /* https://www.codeproject.com/Articles/9600/Windows-SetThreadLocale-and-CRT-setlocale */ + old_lcid = GetThreadLocale (); + SetThreadLocale (MAKELCID (MAKELANGID (LANG_POLISH, SUBLANG_POLISH_POLAND), SORT_DEFAULT)); +#endif + /* In Polish language September is "wrzesień" and August is "sierpień" * abbreviated as "sie". The former used to be confused with the latter * because "sie" is a substring of "wrzesień" and was matched first. */ @@ -1109,6 +1119,9 @@ test_month_substring (void) g_assert_true (g_date_valid (&date)); g_assert_cmpint (g_date_get_month (&date), ==, G_DATE_AUGUST); +#ifdef G_OS_WIN32 + SetThreadLocale (old_lcid); +#endif setlocale (LC_ALL, ""); }