[gnome-desktop] tests: Add a wall clock test for colon vs ratio character use
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] tests: Add a wall clock test for colon vs ratio character use
- Date: Fri, 30 May 2014 12:18:00 +0000 (UTC)
commit 4faf1d2739b19b66ef41b5f35b75f0a7d4382fcc
Author: Kalev Lember <kalevlember gmail com>
Date: Tue May 20 22:15:03 2014 +0200
tests: Add a wall clock test for colon vs ratio character use
https://bugzilla.gnome.org/show_bug.cgi?id=730447
tests/wall-clock.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/tests/wall-clock.c b/tests/wall-clock.c
index aec0579..7e73d0e 100644
--- a/tests/wall-clock.c
+++ b/tests/wall-clock.c
@@ -20,11 +20,50 @@
#include <glib.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-wall-clock.h>
+#include <locale.h>
+#include <string.h>
+
+#define COLON ":"
+#define RATIO "∶"
static void
-test_dummy (void)
+test_colon_vs_ratio (void)
{
- g_assert_cmpint (0, ==, 0);
+ GnomeWallClock *clock;
+ const char *save_locale;
+ const char *str;
+
+ /* 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");
+ clock = gnome_wall_clock_new ();
+ str = gnome_wall_clock_get_clock (clock);
+ g_assert (strstr (str, COLON) != NULL);
+ g_assert (strstr (str, RATIO) == NULL);
+ g_object_unref (clock);
+
+ /* In a UTF8 locale, we want ratio characters and no colons */
+ setlocale (LC_ALL, "en_US.utf8");
+ clock = gnome_wall_clock_new ();
+ str = gnome_wall_clock_get_clock (clock);
+ g_assert (strstr (str, COLON) == NULL);
+ g_assert (strstr (str, RATIO) != NULL);
+ g_object_unref (clock);
+
+ /* ... and same thing with an RTL locale: should be formatted with
+ * ratio characters */
+ setlocale (LC_ALL, "he_IL.utf8");
+ clock = gnome_wall_clock_new ();
+ str = gnome_wall_clock_get_clock (clock);
+ g_assert (strstr (str, COLON) == NULL);
+ g_assert (strstr (str, RATIO) != NULL);
+ g_object_unref (clock);
+
+ /* Restore previous locale */
+ setlocale (LC_ALL, save_locale);
}
int
@@ -33,7 +72,7 @@ main (int argc,
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/wall-clock/dummy", test_dummy);
+ g_test_add_func ("/wall-clock/colon-vs-ratio", test_colon_vs_ratio);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]