summaryrefslogtreecommitdiff
path: root/tests/test-break.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-break.c')
-rw-r--r--tests/test-break.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/tests/test-break.c b/tests/test-break.c
index df9b78e2..c4359643 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -34,7 +34,7 @@
static PangoContext *context;
-static void
+static gboolean
test_file (const gchar *filename, GString *string)
{
gchar *contents;
@@ -62,7 +62,6 @@ test_file (const gchar *filename, GString *string)
length = strlen (test);
len = g_utf8_strlen (test, -1) + 1;
- attrs = g_new (PangoLogAttr, len);
pango_parse_markup (test, -1, 0, &attributes, &text, NULL, &error);
g_assert_no_error (error);
@@ -73,9 +72,17 @@ test_file (const gchar *filename, GString *string)
if (pango_layout_get_unknown_glyphs_count (layout) > 0)
{
+#if 0
+ // See https://github.com/mesonbuild/meson/issues/7515
char *msg = g_strdup_printf ("Missing glyphs - skipping %s. Maybe fonts are missing?", filename);
g_test_skip (msg);
g_free (msg);
+#endif
+ g_free (contents);
+ g_object_unref (layout);
+ pango_attr_list_unref (attributes);
+ g_free (text);
+ return FALSE;
}
pango_layout_get_log_attrs (layout, &attrs, &len);
@@ -221,7 +228,10 @@ test_file (const gchar *filename, GString *string)
g_object_unref (layout);
g_free (attrs);
g_free (contents);
+ g_free (text);
pango_attr_list_unref (attributes);
+
+ return TRUE;
}
static gchar *
@@ -249,26 +259,36 @@ test_break (gconstpointer d)
GString *dump;
gchar *diff;
- const char *old_locale = setlocale (LC_ALL, NULL);
+ char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
setlocale (LC_ALL, "en_US.utf8");
if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
{
+#if 0
+ // See https://github.com/mesonbuild/meson/issues/7515
char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping break %s", filename);
g_test_skip (msg);
g_free (msg);
+#endif
+ g_free (old_locale);
return;
}
- expected_file = get_expected_filename (filename);
-
dump = g_string_sized_new (0);
- test_file (filename, dump);
+ if (!test_file (filename, dump))
+ {
+ g_free (old_locale);
+ g_string_free (dump, TRUE);
+ return;
+ }
+
+ expected_file = get_expected_filename (filename);
diff = diff_with_file (expected_file, dump->str, dump->len, &error);
g_assert_no_error (error);
setlocale (LC_ALL, old_locale);
+ g_free (old_locale);
if (diff && diff[0])
{
@@ -284,9 +304,9 @@ test_break (gconstpointer d)
g_test_fail ();
g_strfreev (lines);
- g_free (diff);
}
+ g_free (diff);
g_string_free (dump, TRUE);
g_free (expected_file);
}
@@ -308,11 +328,26 @@ main (int argc, char *argv[])
/* allow to easily generate expected output for new test cases */
if (argc > 1)
{
- GString *string;
+ if (strcmp (argv[1], "--help") == 0)
+ {
+ g_print ("test-break uses the following symbols for log attrs\n\n");
+ g_print ("Breaks: Words:\n"
+ " L - mandatory break b - word boundary\n"
+ " l - line break s - word start\n"
+ " c - char break e - word end\n"
+ "\n"
+ "Whitespace: Sentences:\n"
+ " x - expandable space s - sentence start\n"
+ " w - whitespace e - sentence end\n");
+ }
+ else
+ {
+ GString *string;
- string = g_string_sized_new (0);
- test_file (argv[1], string);
- g_test_message ("%s", string->str);
+ string = g_string_sized_new (0);
+ test_file (argv[1], string);
+ g_print ("%s", string->str);
+ }
return 0;
}