Commit 5804fa7c authored by Michael Catanzaro's avatar Michael Catanzaro Committed by Michael Catanzaro

tests: Convert second wall clock test to uselocale

parent b87de749
......@@ -36,7 +36,8 @@ test_utf8_character (const char *utf8_char,
{
GDateTime *datetime;
GnomeWallClock *clock;
const char *save_locale;
locale_t locale;
locale_t save_locale;
const char *str;
/* When testing that UTF8 locales don't use double spaces
......@@ -44,12 +45,10 @@ test_utf8_character (const char *utf8_char,
doesn't contain double spaces ("Aug 1") */
datetime = g_date_time_new_local (2014, 5, 28, 23, 59, 59);
/* Save current locale */
save_locale = setlocale (LC_ALL, NULL);
/* In the C locale, make sure the time string is formatted with regular
* colons */
setlocale (LC_ALL, "C");
locale = newlocale (LC_ALL_MASK, "C", (locale_t) 0);
save_locale = uselocale (locale);
clock = gnome_wall_clock_new ();
str = gnome_wall_clock_string_for_datetime (clock,
datetime,
......@@ -59,8 +58,9 @@ test_utf8_character (const char *utf8_char,
g_assert (strstr (str, utf8_char) == NULL);
g_object_unref (clock);
/* In a UTF8 locale, we want ratio characters and no colons */
setlocale (LC_ALL, "en_US.utf8");
/* In a UTF8 locale, we want ratio characters and no colons. */
locale = newlocale (LC_ALL_MASK, "en_US.utf8", locale);
uselocale (locale);
clock = gnome_wall_clock_new ();
str = gnome_wall_clock_string_for_datetime (clock,
datetime,
......@@ -72,7 +72,8 @@ test_utf8_character (const char *utf8_char,
/* ... and same thing with an RTL locale: should be formatted with
* ratio characters */
setlocale (LC_ALL, "he_IL.utf8");
locale = newlocale (LC_ALL_MASK, "he_IL.utf8", locale);
uselocale (locale);
clock = gnome_wall_clock_new ();
str = gnome_wall_clock_string_for_datetime (clock,
datetime,
......@@ -85,7 +86,8 @@ test_utf8_character (const char *utf8_char,
g_date_time_unref (datetime);
/* Restore previous locale */
setlocale (LC_ALL, save_locale);
uselocale (save_locale);
freelocale (locale);
}
static void
......@@ -105,13 +107,13 @@ test_clock_format_setting (void)
{
GnomeWallClock *clock;
GSettings *settings;
const char *save_locale;
locale_t locale;
locale_t save_locale;
const char *str;
/* Save current locale */
save_locale = setlocale (LC_ALL, NULL);
locale = newlocale (LC_ALL_MASK, "en_US.utf8", (locale_t) 0);
save_locale = uselocale (locale);
setlocale (LC_ALL, "en_US.utf8");
settings = g_settings_new ("org.gnome.desktop.interface");
/* In 12h format, the string ends with AM or PM */
......@@ -131,7 +133,8 @@ test_clock_format_setting (void)
g_object_unref (settings);
/* Restore previous locale */
setlocale (LC_ALL, save_locale);
uselocale (save_locale);
freelocale (locale);
}
static gboolean
......@@ -183,13 +186,13 @@ test_weekday_setting (void)
{
GnomeWallClock *clock;
GSettings *settings;
const char *save_locale;
locale_t locale;
locale_t save_locale;
const char *str, *ptr, *s;
/* Save current locale */
save_locale = setlocale (LC_ALL, NULL);
setlocale (LC_ALL, "C");
locale = newlocale (LC_ALL_MASK, "C", (locale_t) 0);
save_locale = uselocale (locale);
settings = g_settings_new ("org.gnome.desktop.interface");
/* Set 24h format, so that the only alphabetical part will be the weekday */
......@@ -225,7 +228,8 @@ test_weekday_setting (void)
g_object_unref (settings);
/* Restore previous locale */
setlocale (LC_ALL, save_locale);
uselocale (save_locale);
freelocale (locale);
}
int
......
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