[glib: 3/5] glib/tests: set Polish ThreadLocale on win32 to fix a test
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 3/5] glib/tests: set Polish ThreadLocale on win32 to fix a test
- Date: Wed, 16 Feb 2022 00:07:54 +0000 (UTC)
commit f7c66423a41a57b0ec43cddf0fc9de949ab3fed1
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Tue Jan 25 02:03:38 2022 +0400
glib/tests: set Polish ThreadLocale on win32 to fix a test
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 <marcandre lureau redhat com>
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, "");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]