[gnome-desktop: 3/6] tests: Test correct space vs. em-space handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop: 3/6] tests: Test correct space vs. em-space handling
- Date: Wed, 1 Aug 2018 19:40:05 +0000 (UTC)
commit 0599decdfdec877822c721114f892e35cd799c4f
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jul 30 23:59:50 2018 +0200
tests: Test correct space vs. em-space handling
This is analogous to the existing colon vs. ratio test which checks
that:
- UTF8 locales use the UTF8 character
(in both LTR and RTL locales)
- non-UTF8 locales use an appropriate
ASCII replacement
tests/wall-clock.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/tests/wall-clock.c b/tests/wall-clock.c
index 4c57d3ec..5200cf89 100644
--- a/tests/wall-clock.c
+++ b/tests/wall-clock.c
@@ -27,8 +27,12 @@
#define COLON ":"
#define RATIO "∶"
+#define SPACE " "
+#define EM_SPACE " "
+
static void
-test_colon_vs_ratio (void)
+test_utf8_character (const char *utf8_char,
+ const char *non_utf8_fallback)
{
GnomeWallClock *clock;
const char *save_locale;
@@ -42,16 +46,16 @@ test_colon_vs_ratio (void)
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_assert (strstr (str, non_utf8_fallback) != NULL);
+ 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");
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_assert (strstr (str, non_utf8_fallback) == NULL);
+ g_assert (strstr (str, utf8_char) != NULL);
g_object_unref (clock);
/* ... and same thing with an RTL locale: should be formatted with
@@ -59,14 +63,26 @@ test_colon_vs_ratio (void)
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_assert (strstr (str, non_utf8_fallback) == NULL);
+ g_assert (strstr (str, utf8_char) != NULL);
g_object_unref (clock);
/* Restore previous locale */
setlocale (LC_ALL, save_locale);
}
+static void
+test_colon_vs_ratio (void)
+{
+ test_utf8_character (RATIO, COLON);
+}
+
+static void
+test_space_vs_em_space (void)
+{
+ test_utf8_character (EM_SPACE, SPACE);
+}
+
static void
test_clock_format_setting (void)
{
@@ -203,6 +219,7 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/wall-clock/colon-vs-ratio", test_colon_vs_ratio);
+ g_test_add_func ("/wall-clock/space-vs-em-space", test_space_vs_em_space);
g_test_add_func ("/wall-clock/24h-clock-format", test_clock_format_setting);
g_test_add_func ("/wall-clock/notify-clock", test_notify_clock);
g_test_add_func ("/wall-clock/weekday-setting", test_weekday_setting);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]