summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2014-02-20 11:48:00 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2019-06-13 17:08:21 +0800
commit14c53f9f20c5e918256333adc1c991889bcb7657 (patch)
tree63c4f89df97650ca2bdcdb59570c4c742b84c1cd
parent3b038b8978c0df4cd76b5fd873feb992052186c1 (diff)
downloadglib-14c53f9f20c5e918256333adc1c991889bcb7657.tar.gz
Update the gdatetime Test Program for Windows
Update the gdatetime test program to make use of the updates that was done in gtimezone.c in the previous commit, so that we don't have to worry what language version of Windows the tests are being run in, but instead be assured that we produce and check for the English-language time zone name strings. Also, instead of testing for "Pacific Standard Time" in test_GDAteTime_printf(), use GetDynamicTimeZoneInformation() to get the actual time zone string (where the system running the test program is) we want to check for. https://bugzilla.gnome.org/show_bug.cgi?id=719344
-rw-r--r--glib/tests/gdatetime.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 00e22181e..4e6559ad8 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -25,6 +25,11 @@
#include <glib/gstdio.h>
#include <locale.h>
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
#define ASSERT_DATE(dt,y,m,d) G_STMT_START { \
g_assert_nonnull ((dt)); \
g_assert_cmpint ((y), ==, g_date_time_get_year ((dt))); \
@@ -1029,6 +1034,13 @@ test_GDateTime_new_full (void)
GTimeZone *tz, *dt_tz;
GDateTime *dt;
+#ifdef G_OS_WIN32
+ LCID currLcid = GetThreadLocale ();
+ LANGID currLangId = LANGIDFROMLCID (currLcid);
+ LANGID en = MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US);
+ SetThreadUILanguage (en);
+#endif
+
dt = g_date_time_new_utc (2009, 12, 11, 12, 11, 10);
g_assert_cmpint (2009, ==, g_date_time_get_year (dt));
g_assert_cmpint (12, ==, g_date_time_get_month (dt));
@@ -1063,6 +1075,7 @@ test_GDateTime_new_full (void)
g_date_time_get_timezone_abbreviation (dt));
g_assert_cmpstr ("Pacific Standard Time", ==,
g_time_zone_get_identifier (dt_tz));
+ SetThreadUILanguage (currLangId);
#endif
g_assert (!g_date_time_is_daylight_savings (dt));
g_date_time_unref (dt);
@@ -1331,6 +1344,15 @@ test_GDateTime_printf (void)
gchar dst[64];
struct tm tt;
time_t t;
+#ifdef G_OS_WIN32
+ gchar *current_tz = NULL;
+ DYNAMIC_TIME_ZONE_INFORMATION dtz_info;
+ LCID currLcid = GetThreadLocale ();
+ LANGID currLangId = LANGIDFROMLCID (currLcid);
+ LANGID en = MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US);
+
+ SetThreadUILanguage (en);
+#endif
#define TEST_PRINTF(f,o) G_STMT_START { \
GDateTime *__dt = g_date_time_new_local (2009, 10, 24, 0, 0, 0);\
@@ -1426,7 +1448,14 @@ GDateTime *__dt = g_date_time_new_local (2009, 10, 24, 0, 0, 0);\
#ifdef G_OS_UNIX
TEST_PRINTF ("%Z", dst);
#elif defined G_OS_WIN32
- TEST_PRINTF ("%Z", "Pacific Standard Time");
+ g_assert (GetDynamicTimeZoneInformation (&dtz_info) != TIME_ZONE_ID_INVALID);
+ if (wcscmp (dtz_info.StandardName, L"") != 0)
+ current_tz = g_utf16_to_utf8 (dtz_info.StandardName, -1, NULL, NULL, NULL);
+ else
+ current_tz = g_utf16_to_utf8 (dtz_info.DaylightName, -1, NULL, NULL, NULL);
+ TEST_PRINTF ("%Z", current_tz);
+ g_free (current_tz);
+ SetThreadUILanguage (currLangId);
#endif
if (old_lc_messages != NULL)