summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-06-28 04:15:40 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-06-28 04:15:40 +0000
commit249615a89cc1594e7c16b5cc5004f63ca9eb36b6 (patch)
treec8d0e13454759394355c16ec94b31d14f3f671f1
parentc463e096e119abb9b65b74c078ee1f2b1aae8c30 (diff)
parent034273de5cbe867348fa687845c8e63dc44a7148 (diff)
downloadpango-249615a89cc1594e7c16b5cc5004f63ca9eb36b6.tar.gz
Merge branch 'test-coverage' into 'master'
Add better attribute test infrastructure See merge request GNOME/pango!346
-rw-r--r--pango/pango-bidi-type.c7
-rw-r--r--pango/pango-bidi-type.h12
-rw-r--r--pango/pango-markup.c32
-rw-r--r--pango/pango-matrix.c13
-rw-r--r--pango/pango-tabs.c2
-rw-r--r--pango/pango-utils.c2
-rw-r--r--tests/markup-parse.c125
-rw-r--r--tests/markups/fail-10.expected1
-rw-r--r--tests/markups/fail-10.markup11
-rw-r--r--tests/markups/fail-11.expected1
-rw-r--r--tests/markups/fail-11.markup1
-rw-r--r--tests/markups/fail-12.expected1
-rw-r--r--tests/markups/fail-12.markup1
-rw-r--r--tests/markups/fail-13.expected1
-rw-r--r--tests/markups/fail-13.markup1
-rw-r--r--tests/markups/fail-14.expected1
-rw-r--r--tests/markups/fail-14.markup1
-rw-r--r--tests/markups/fail-15.expected1
-rw-r--r--tests/markups/fail-15.markup1
-rw-r--r--tests/markups/fail-16.expected1
-rw-r--r--tests/markups/fail-16.markup1
-rw-r--r--tests/markups/fail-17.expected1
-rw-r--r--tests/markups/fail-17.markup1
-rw-r--r--tests/markups/fail-19.expected1
-rw-r--r--tests/markups/fail-19.markup1
-rw-r--r--tests/markups/fail-20.expected1
-rw-r--r--tests/markups/fail-20.markup1
-rw-r--r--tests/markups/fail-21.expected1
-rw-r--r--tests/markups/fail-21.markup1
-rw-r--r--tests/markups/fail-22.expected1
-rw-r--r--tests/markups/fail-22.markup1
-rw-r--r--tests/markups/fail-23.expected1
-rw-r--r--tests/markups/fail-23.markup1
-rw-r--r--tests/markups/fail-24.expected1
-rw-r--r--tests/markups/fail-24.markup1
-rw-r--r--tests/markups/fail-25.expected1
-rw-r--r--tests/markups/fail-25.markup1
-rw-r--r--tests/markups/fail-26.expected1
-rw-r--r--tests/markups/fail-26.markup1
-rw-r--r--tests/markups/fail-27.expected1
-rw-r--r--tests/markups/fail-27.markup1
-rw-r--r--tests/markups/fail-28.expected1
-rw-r--r--tests/markups/fail-28.markup1
-rw-r--r--tests/markups/fail-29.expected1
-rw-r--r--tests/markups/fail-29.markup1
-rw-r--r--tests/markups/fail-30.expected1
-rw-r--r--tests/markups/fail-30.markup1
-rw-r--r--tests/markups/fail-31.expected1
-rw-r--r--tests/markups/fail-31.markup1
-rw-r--r--tests/markups/fail-32.expected1
-rw-r--r--tests/markups/fail-32.markup1
-rw-r--r--tests/markups/fail-33.expected1
-rw-r--r--tests/markups/fail-33.markup1
-rw-r--r--tests/markups/fail-34.expected1
-rw-r--r--tests/markups/fail-34.markup1
-rw-r--r--tests/markups/fail-35.expected1
-rw-r--r--tests/markups/fail-35.markup1
-rw-r--r--tests/markups/fail-36.expected1
-rw-r--r--tests/markups/fail-36.markup1
-rw-r--r--tests/markups/fail-37.expected1
-rw-r--r--tests/markups/fail-37.markup1
-rw-r--r--tests/markups/fail-38.expected1
-rw-r--r--tests/markups/fail-38.markup1
-rw-r--r--tests/markups/fail-39.expected1
-rw-r--r--tests/markups/fail-39.markup1
-rw-r--r--tests/markups/fail-6.expected1
-rw-r--r--tests/markups/fail-6.markup1
-rw-r--r--tests/markups/fail-7.expected1
-rw-r--r--tests/markups/fail-7.markup1
-rw-r--r--tests/markups/fail-8.expected1
-rw-r--r--tests/markups/fail-8.markup1
-rw-r--r--tests/markups/fail-9.expected1
-rw-r--r--tests/markups/fail-9.markup11
-rw-r--r--tests/markups/valid-10.markup4
-rw-r--r--tests/markups/valid-11.markup4
-rw-r--r--tests/markups/valid-16.expected27
-rw-r--r--tests/markups/valid-16.markup1
-rw-r--r--tests/markups/valid-17.expected14
-rw-r--r--tests/markups/valid-17.markup1
-rw-r--r--tests/markups/valid-18.expected24
-rw-r--r--tests/markups/valid-18.markup11
-rw-r--r--tests/markups/valid-19.expected18
-rw-r--r--tests/markups/valid-19.markup5
-rw-r--r--tests/markups/valid-2.expected2
-rw-r--r--tests/markups/valid-2.markup2
-rw-r--r--tests/markups/valid-3.expected1
-rw-r--r--tests/markups/valid-3.markup1
-rw-r--r--tests/markups/valid-8.expected67
-rw-r--r--tests/markups/valid-8.markup13
-rw-r--r--tests/meson.build43
-rw-r--r--tests/test-common.c217
-rw-r--r--tests/test-common.h7
-rw-r--r--tests/test-font.c71
-rw-r--r--tests/testattributes.c313
-rw-r--r--tests/testcolor.c30
-rw-r--r--tests/testcontext.c145
-rw-r--r--tests/testlanguage.c67
-rw-r--r--tests/testmatrix.c205
-rw-r--r--tests/testmisc.c149
-rw-r--r--tests/testtabs.c110
100 files changed, 1557 insertions, 274 deletions
diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c
index 8700836b..a5a13a9a 100644
--- a/pango/pango-bidi-type.c
+++ b/pango/pango-bidi-type.c
@@ -79,10 +79,11 @@ pango_bidi_type_for_unichar (gunichar ch)
case FRIBIDI_TYPE_SS: return PANGO_BIDI_TYPE_S;
case FRIBIDI_TYPE_WS: return PANGO_BIDI_TYPE_WS;
case FRIBIDI_TYPE_ON: return PANGO_BIDI_TYPE_ON;
+ case FRIBIDI_TYPE_LRI: return PANGO_BIDI_TYPE_LRI;
+ case FRIBIDI_TYPE_RLI: return PANGO_BIDI_TYPE_RLI;
+ case FRIBIDI_TYPE_FSI: return PANGO_BIDI_TYPE_FSI;
+ case FRIBIDI_TYPE_PDI: return PANGO_BIDI_TYPE_PDI;
default:
- /* TODO
- * This function has not been updated for latest FriBidi.
- * Should add new types and / or deprecate this function. */
return PANGO_BIDI_TYPE_ON;
}
}
diff --git a/pango/pango-bidi-type.h b/pango/pango-bidi-type.h
index 2f1dfd1d..a1fd0c69 100644
--- a/pango/pango-bidi-type.h
+++ b/pango/pango-bidi-type.h
@@ -51,6 +51,10 @@ G_BEGIN_DECLS
* @PANGO_BIDI_TYPE_S: Segment Separator
* @PANGO_BIDI_TYPE_WS: Whitespace
* @PANGO_BIDI_TYPE_ON: Other Neutrals
+ * @PANGO_BIDI_TYPE_LRI: Left-to-Right isolate. Since 1.48.6
+ * @PANGO_BIDI_TYPE_RLI: Right-to-Left isolate. Since 1.48.6
+ * @PANGO_BIDI_TYPE_FSI: First strong isolate. Since 1.48.6
+ * @PANGO_BIDI_TYPE_PDI: Pop directional isolate. Since 1.48.6
*
* `PangoBidiType` represents the bidirectional character
* type of a Unicode character as specified by the
@@ -83,7 +87,13 @@ typedef enum {
PANGO_BIDI_TYPE_B,
PANGO_BIDI_TYPE_S,
PANGO_BIDI_TYPE_WS,
- PANGO_BIDI_TYPE_ON
+ PANGO_BIDI_TYPE_ON,
+
+ /* Explicit formatting */
+ PANGO_BIDI_TYPE_LRI,
+ PANGO_BIDI_TYPE_RLI,
+ PANGO_BIDI_TYPE_FSI,
+ PANGO_BIDI_TYPE_PDI
} PangoBidiType;
PANGO_DEPRECATED_IN_1_44
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 258ca717..38e908c5 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -584,17 +584,10 @@ pango_markup_parser_new_internal (char accel_marker,
0, md,
(GDestroyNotify)destroy_markup_data);
- if (!g_markup_parse_context_parse (context,
- "<markup>",
- -1,
- error))
- goto error;
+ if (!g_markup_parse_context_parse (context, "<markup>", -1, error))
+ g_clear_pointer (&context, g_markup_parse_context_free);
return context;
-
- error:
- g_markup_parse_context_free (context);
- return NULL;
}
/**
@@ -654,8 +647,6 @@ pango_parse_markup (const char *markup_text,
context = pango_markup_parser_new_internal (accel_marker,
error,
(attr_list != NULL));
- if (context == NULL)
- goto out;
if (!g_markup_parse_context_parse (context,
markup_text,
@@ -711,16 +702,9 @@ pango_parse_markup (const char *markup_text,
* Since: 1.31.0
**/
GMarkupParseContext *
-pango_markup_parser_new (gunichar accel_marker)
+pango_markup_parser_new (gunichar accel_marker)
{
- GError *error = NULL;
- GMarkupParseContext *context;
- context = pango_markup_parser_new_internal (accel_marker, &error, TRUE);
-
- if (context == NULL)
- g_critical ("Had error when making markup parser: %s\n", error->message);
-
- return context;
+ return pango_markup_parser_new_internal (accel_marker, NULL, TRUE);
}
/**
@@ -1245,11 +1229,16 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
CHECK_ATTRIBUTE (underline);
CHECK_ATTRIBUTE (underline_color);
break;
- default:
+ case 'r':
CHECK_ATTRIBUTE (rise);
+ break;
+ case 'v':
CHECK_ATTRIBUTE (variant);
+ break;
+ case 'w':
CHECK_ATTRIBUTE (weight);
break;
+ default:;
}
if (!found)
@@ -1657,6 +1646,7 @@ markup_parse_func (MarkupData *md G_GNUC_UNUSED,
GError **error G_GNUC_UNUSED)
{
/* We don't do anything with this tag at the moment. */
+ CHECK_NO_ATTRS("markup");
return TRUE;
}
diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c
index 666fe55a..a066eb57 100644
--- a/pango/pango-matrix.c
+++ b/pango/pango-matrix.c
@@ -461,17 +461,18 @@ pango_matrix_transform_pixel_rectangle (const PangoMatrix *matrix,
min_x = max_x = quad_x[0];
min_y = max_y = quad_y[0];
- for (i=1; i < 4; i++) {
+ for (i=1; i < 4; i++)
+ {
if (quad_x[i] < min_x)
- min_x = quad_x[i];
+ min_x = quad_x[i];
else if (quad_x[i] > max_x)
- max_x = quad_x[i];
+ max_x = quad_x[i];
if (quad_y[i] < min_y)
- min_y = quad_y[i];
+ min_y = quad_y[i];
else if (quad_y[i] > max_y)
- max_y = quad_y[i];
- }
+ max_y = quad_y[i];
+ }
rect->x = floor (min_x);
rect->y = floor (min_y);
diff --git a/pango/pango-tabs.c b/pango/pango-tabs.c
index 0792cd5a..28027454 100644
--- a/pango/pango-tabs.c
+++ b/pango/pango-tabs.c
@@ -113,7 +113,7 @@ pango_tab_array_new (gint initial_size,
* @first_position: position of first tab stop
* @...: additional alignment/position pairs
*
- * Creates * a `PangoTabArray` and allows you to specify the alignment
+ * Creates a `PangoTabArray` and allows you to specify the alignment
* and position of each tab stop.
*
* You **must** provide an alignment and position for @size tab stops.
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index 0057859e..c90b4c86 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -127,6 +127,8 @@ pango_version_check (int required_major,
gint pango_effective_micro = 100 * PANGO_VERSION_MINOR + PANGO_VERSION_MICRO;
gint required_effective_micro = 100 * required_minor + required_micro;
+ if (required_major > PANGO_VERSION_MAJOR)
+ return "Pango version too old (major mismatch)";
if (required_major < PANGO_VERSION_MAJOR)
return "Pango version too new (major mismatch)";
if (required_effective_micro < pango_effective_micro - PANGO_BINARY_AGE)
diff --git a/tests/markup-parse.c b/tests/markup-parse.c
index 9f081ab7..fbe14402 100644
--- a/tests/markup-parse.c
+++ b/tests/markup-parse.c
@@ -53,7 +53,6 @@ test_file (const gchar *filename, GString *string)
g_assert_no_error (error);
ret = pango_parse_markup (contents, length, '_', &attrs, &text, &accel, &error);
- g_free (contents);
if (ret)
{
@@ -81,12 +80,18 @@ test_file (const gchar *filename, GString *string)
g_string_append (string, "\n\n---\n\n");
g_string_append_unichar (string, accel);
}
+
+ /* Check that all optional arguments can be NULL */
+ ret = pango_parse_markup (contents, length, '_', NULL, NULL, NULL, NULL);
+ g_assert_true (ret);
}
else
{
g_string_append_printf (string, "ERROR: %s", error->message);
g_error_free (error);
}
+
+ g_free (contents);
}
static gchar *
@@ -135,6 +140,119 @@ test_parse (gconstpointer d)
g_free (expected_file);
}
+static void
+test_file_incrementally (const gchar *filename, GString *string)
+{
+ gchar *contents;
+ gsize length;
+ GError *error = NULL;
+ gchar *text;
+ PangoAttrList *attrs;
+ PangoAttrIterator *iter;
+ PangoFontDescription *desc;
+ PangoLanguage *lang;
+ gboolean ret;
+ char *str;
+ int start, end;
+ gunichar accel = 0;
+ GMarkupParseContext *ctx;
+
+ g_file_get_contents (filename, &contents, &length, &error);
+ g_assert_no_error (error);
+
+ ctx = pango_markup_parser_new ('_');
+
+ ret = TRUE;
+ for (int i = 0; i < length; i++)
+ {
+ ret = g_markup_parse_context_parse (ctx, &contents[i], 1, &error);
+ if (!ret)
+ break;
+ }
+
+ g_free (contents);
+
+ if (ret)
+ {
+ pango_markup_parser_finish (ctx, &attrs, &text, &accel, &error);
+
+ g_assert_no_error (error);
+ g_string_append (string, text);
+ g_string_append (string, "\n\n---\n\n");
+ print_attr_list (attrs, string);
+ g_string_append (string, "\n\n---\n\n");
+ desc = pango_font_description_new ();
+ iter = pango_attr_list_get_iterator (attrs);
+ do {
+ pango_attr_iterator_range (iter, &start, &end);
+ pango_attr_iterator_get_font (iter, desc, &lang, NULL);
+ str = pango_font_description_to_string (desc);
+ g_string_append_printf (string, "[%d:%d] %s %s\n", start, end, (char *)lang, str);
+ g_free (str);
+ } while (pango_attr_iterator_next (iter));
+ pango_attr_iterator_destroy (iter);
+ pango_attr_list_unref (attrs);
+ pango_font_description_free (desc);
+ g_free (text);
+
+ if (accel)
+ {
+ g_string_append (string, "\n\n---\n\n");
+ g_string_append_unichar (string, accel);
+ }
+ }
+ else
+ {
+ g_string_append_printf (string, "ERROR: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_markup_parse_context_free (ctx);
+}
+
+static void
+test_parse_incrementally (gconstpointer d)
+{
+ const gchar *filename = d;
+ gchar *expected_file;
+ GError *error = NULL;
+ GString *string;
+ char *diff;
+ gboolean ret;
+
+ expected_file = get_expected_filename (filename);
+
+ string = g_string_sized_new (0);
+
+ test_file_incrementally (filename, string);
+
+ /* incremental parsing can affect line numbers,
+ * so avoid comparing the exact error strings
+ */
+ if (g_str_has_prefix (string->str, "ERROR:"))
+ {
+ ret = file_has_prefix (expected_file, "ERROR:", &error);
+ g_assert_no_error (error);
+ g_assert_true (ret);
+ }
+ else
+ {
+ diff = diff_with_file (expected_file, string->str, string->len, &error);
+ g_assert_no_error (error);
+
+ if (diff && diff[0])
+ {
+ g_test_message ("Resulting output doesn't match reference:\n%s", diff);
+ g_test_fail ();
+ }
+ g_free (diff);
+ }
+
+ g_string_free (string, TRUE);
+
+ g_free (expected_file);
+}
+
int
main (int argc, char *argv[])
{
@@ -173,6 +291,11 @@ main (int argc, char *argv[])
g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DIST, "markups", name, NULL),
test_parse, g_free);
g_free (path);
+
+ path = g_strdup_printf ("/markup/parse-incrementally/%s", name);
+ g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DIST, "markups", name, NULL),
+ test_parse_incrementally, g_free);
+ g_free (path);
}
g_dir_close (dir);
diff --git a/tests/markups/fail-10.expected b/tests/markups/fail-10.expected
new file mode 100644
index 00000000..cb7b6f16
--- /dev/null
+++ b/tests/markups/fail-10.expected
@@ -0,0 +1 @@
+ERROR: Value of 'fallback' attribute on <span> tag line 11 should have one of 'true/yes/t/y' or 'false/no/f/n': 'x' is not valid \ No newline at end of file
diff --git a/tests/markups/fail-10.markup b/tests/markups/fail-10.markup
new file mode 100644
index 00000000..692f49a9
--- /dev/null
+++ b/tests/markups/fail-10.markup
@@ -0,0 +1,11 @@
+<span font="Sans Italic 12"
+ foreground="#00ff00"
+ background="#f0f0f0"
+ underline="double"
+ underline_color="red"
+ strikethrough="true"
+ strikethrough_color="blue"
+ fallback="x"
+ lang="de"
+ gravity="south"
+ gravity_hint="strong">Lots of attrs</span>
diff --git a/tests/markups/fail-11.expected b/tests/markups/fail-11.expected
new file mode 100644
index 00000000..96cac741
--- /dev/null
+++ b/tests/markups/fail-11.expected
@@ -0,0 +1 @@
+ERROR: Value of 'rise' attribute on <span> tag on line 1 could not be parsed; should be an integer, not 'sky' \ No newline at end of file
diff --git a/tests/markups/fail-11.markup b/tests/markups/fail-11.markup
new file mode 100644
index 00000000..f33a2ec7
--- /dev/null
+++ b/tests/markups/fail-11.markup
@@ -0,0 +1 @@
+<span rise="sky">test</span>
diff --git a/tests/markups/fail-12.expected b/tests/markups/fail-12.expected
new file mode 100644
index 00000000..44893dd3
--- /dev/null
+++ b/tests/markups/fail-12.expected
@@ -0,0 +1 @@
+ERROR: Value of 'alpha' attribute on <span> tag on line 1 could not be parsed; should be between 0 and 65536 or a percentage, not 'seethru' \ No newline at end of file
diff --git a/tests/markups/fail-12.markup b/tests/markups/fail-12.markup
new file mode 100644
index 00000000..3eda2059
--- /dev/null
+++ b/tests/markups/fail-12.markup
@@ -0,0 +1 @@
+<span alpha="seethru">test</span>
diff --git a/tests/markups/fail-13.expected b/tests/markups/fail-13.expected
new file mode 100644
index 00000000..8353cd34
--- /dev/null
+++ b/tests/markups/fail-13.expected
@@ -0,0 +1 @@
+ERROR: 'all' is not a valid value for the 'show' attribute on <span> tag, line 1; valid values are none/spaces/line-breaks/ignorables or combinations with | \ No newline at end of file
diff --git a/tests/markups/fail-13.markup b/tests/markups/fail-13.markup
new file mode 100644
index 00000000..01b2986a
--- /dev/null
+++ b/tests/markups/fail-13.markup
@@ -0,0 +1 @@
+<span show="all">test</span>
diff --git a/tests/markups/fail-14.expected b/tests/markups/fail-14.expected
new file mode 100644
index 00000000..adc4ee86
--- /dev/null
+++ b/tests/markups/fail-14.expected
@@ -0,0 +1 @@
+ERROR: 'moon' is not a valid value for the 'gravity' attribute on <span> tag, line 1; valid values are south/east/north/west/auto \ No newline at end of file
diff --git a/tests/markups/fail-14.markup b/tests/markups/fail-14.markup
new file mode 100644
index 00000000..524ba026
--- /dev/null
+++ b/tests/markups/fail-14.markup
@@ -0,0 +1 @@
+<span gravity="moon">test</span>
diff --git a/tests/markups/fail-15.expected b/tests/markups/fail-15.expected
new file mode 100644
index 00000000..2ae2ee37
--- /dev/null
+++ b/tests/markups/fail-15.expected
@@ -0,0 +1 @@
+ERROR: 'funny' is not a valid value for the 'style' attribute on <span> tag, line 1; valid values are 'normal', 'oblique', 'italic' \ No newline at end of file
diff --git a/tests/markups/fail-15.markup b/tests/markups/fail-15.markup
new file mode 100644
index 00000000..cd533b4d
--- /dev/null
+++ b/tests/markups/fail-15.markup
@@ -0,0 +1 @@
+<span style="funny">test</span>
diff --git a/tests/markups/fail-16.expected b/tests/markups/fail-16.expected
new file mode 100644
index 00000000..b3c23080
--- /dev/null
+++ b/tests/markups/fail-16.expected
@@ -0,0 +1 @@
+ERROR: 'over' is not a valid value for the 'weight' attribute on <span> tag, line 1; valid values are for example 'light', 'ultrabold' or a number \ No newline at end of file
diff --git a/tests/markups/fail-16.markup b/tests/markups/fail-16.markup
new file mode 100644
index 00000000..b3b6e789
--- /dev/null
+++ b/tests/markups/fail-16.markup
@@ -0,0 +1 @@
+<span weight="over">test</span>
diff --git a/tests/markups/fail-17.expected b/tests/markups/fail-17.expected
new file mode 100644
index 00000000..fb55ffbf
--- /dev/null
+++ b/tests/markups/fail-17.expected
@@ -0,0 +1 @@
+ERROR: 'auto' is not a valid value for the 'stretch' attribute on <span> tag, line 1; valid values are for example 'south', 'east', 'north', 'west' \ No newline at end of file
diff --git a/tests/markups/fail-17.markup b/tests/markups/fail-17.markup
new file mode 100644
index 00000000..ce9da312
--- /dev/null
+++ b/tests/markups/fail-17.markup
@@ -0,0 +1 @@
+<span gravity="auto">test</span>
diff --git a/tests/markups/fail-19.expected b/tests/markups/fail-19.expected
new file mode 100644
index 00000000..2627110c
--- /dev/null
+++ b/tests/markups/fail-19.expected
@@ -0,0 +1 @@
+ERROR: Value of 'size' attribute on <span> tag on line 1 could not be parsed; should be an integer no more than 2147483647, or a string such as 'small', not '20px' \ No newline at end of file
diff --git a/tests/markups/fail-19.markup b/tests/markups/fail-19.markup
new file mode 100644
index 00000000..726022e1
--- /dev/null
+++ b/tests/markups/fail-19.markup
@@ -0,0 +1 @@
+<span size="20px">test</span>
diff --git a/tests/markups/fail-20.expected b/tests/markups/fail-20.expected
new file mode 100644
index 00000000..ae9a7df8
--- /dev/null
+++ b/tests/markups/fail-20.expected
@@ -0,0 +1 @@
+ERROR: 'fancy' is not a valid value for the 'variant' attribute on <span> tag, line 1; valid values are 'normal', 'smallcaps' \ No newline at end of file
diff --git a/tests/markups/fail-20.markup b/tests/markups/fail-20.markup
new file mode 100644
index 00000000..86b65952
--- /dev/null
+++ b/tests/markups/fail-20.markup
@@ -0,0 +1 @@
+<span variant="fancy">test</span>
diff --git a/tests/markups/fail-21.expected b/tests/markups/fail-21.expected
new file mode 100644
index 00000000..1e21d89e
--- /dev/null
+++ b/tests/markups/fail-21.expected
@@ -0,0 +1 @@
+ERROR: 'ultra' is not a valid value for the 'stretch' attribute on <span> tag, line 1; valid values are for example 'condensed', 'ultraexpanded', 'normal' \ No newline at end of file
diff --git a/tests/markups/fail-21.markup b/tests/markups/fail-21.markup
new file mode 100644
index 00000000..ee30bca5
--- /dev/null
+++ b/tests/markups/fail-21.markup
@@ -0,0 +1 @@
+<span stretch="ultra">test</span>
diff --git a/tests/markups/fail-22.expected b/tests/markups/fail-22.expected
new file mode 100644
index 00000000..60edc31c
--- /dev/null
+++ b/tests/markups/fail-22.expected
@@ -0,0 +1 @@
+ERROR: Value of 'foreground' attribute on <span> tag on line 1 could not be parsed; should be a color specification, not 'shubidoo' \ No newline at end of file
diff --git a/tests/markups/fail-22.markup b/tests/markups/fail-22.markup
new file mode 100644
index 00000000..93b8e6bb
--- /dev/null
+++ b/tests/markups/fail-22.markup
@@ -0,0 +1 @@
+<span color="shubidoo">test</span>
diff --git a/tests/markups/fail-23.expected b/tests/markups/fail-23.expected
new file mode 100644
index 00000000..17bc6113
--- /dev/null
+++ b/tests/markups/fail-23.expected
@@ -0,0 +1 @@
+ERROR: Value of 'background' attribute on <span> tag on line 1 could not be parsed; should be a color specification, not 'shubidoo' \ No newline at end of file
diff --git a/tests/markups/fail-23.markup b/tests/markups/fail-23.markup
new file mode 100644
index 00000000..f49c175a
--- /dev/null
+++ b/tests/markups/fail-23.markup
@@ -0,0 +1 @@
+<span background="shubidoo">test</span>
diff --git a/tests/markups/fail-24.expected b/tests/markups/fail-24.expected
new file mode 100644
index 00000000..50dca439
--- /dev/null
+++ b/tests/markups/fail-24.expected
@@ -0,0 +1 @@
+ERROR: Value of 'letter_spacing' attribute on <span> tag on line 1 could not be parsed; should be an integer, not '9999999999999' \ No newline at end of file
diff --git a/tests/markups/fail-24.markup b/tests/markups/fail-24.markup
new file mode 100644
index 00000000..effdd0e6
--- /dev/null
+++ b/tests/markups/fail-24.markup
@@ -0,0 +1 @@
+<span letter_spacing="9999999999999">test</span>
diff --git a/tests/markups/fail-25.expected b/tests/markups/fail-25.expected
new file mode 100644
index 00000000..482a55d7
--- /dev/null
+++ b/tests/markups/fail-25.expected
@@ -0,0 +1 @@
+ERROR: Value of 'alpha' attribute on <span> tag on line 1 could not be parsed; should be an integer, not '9999999999999' \ No newline at end of file
diff --git a/tests/markups/fail-25.markup b/tests/markups/fail-25.markup
new file mode 100644
index 00000000..4263023f
--- /dev/null
+++ b/tests/markups/fail-25.markup
@@ -0,0 +1 @@
+<span alpha="9999999999999">test</span>
diff --git a/tests/markups/fail-26.expected b/tests/markups/fail-26.expected
new file mode 100644
index 00000000..73ab1be1
--- /dev/null
+++ b/tests/markups/fail-26.expected
@@ -0,0 +1 @@
+ERROR: Value of 'background_alpha' attribute on <span> tag on line 1 could not be parsed; should be an integer, not '9999999999999' \ No newline at end of file
diff --git a/tests/markups/fail-26.markup b/tests/markups/fail-26.markup
new file mode 100644
index 00000000..11d9802a
--- /dev/null
+++ b/tests/markups/fail-26.markup
@@ -0,0 +1 @@
+<span bgalpha="9999999999999">test</span>
diff --git a/tests/markups/fail-27.expected b/tests/markups/fail-27.expected
new file mode 100644
index 00000000..0f3610ba
--- /dev/null
+++ b/tests/markups/fail-27.expected
@@ -0,0 +1 @@
+ERROR: 'dotted' is not a valid value for the 'underline' attribute on <span> tag, line 1; valid values are none/single/double/low/error/single-line/double-line/error-line \ No newline at end of file
diff --git a/tests/markups/fail-27.markup b/tests/markups/fail-27.markup
new file mode 100644
index 00000000..33f0389c
--- /dev/null
+++ b/tests/markups/fail-27.markup
@@ -0,0 +1 @@
+<span underline="dotted">test</span>
diff --git a/tests/markups/fail-28.expected b/tests/markups/fail-28.expected
new file mode 100644
index 00000000..c0184743
--- /dev/null
+++ b/tests/markups/fail-28.expected
@@ -0,0 +1 @@
+ERROR: 'dotted' is not a valid value for the 'overline' attribute on <span> tag, line 1; valid values are none/single \ No newline at end of file
diff --git a/tests/markups/fail-28.markup b/tests/markups/fail-28.markup
new file mode 100644
index 00000000..be7e28ed
--- /dev/null
+++ b/tests/markups/fail-28.markup
@@ -0,0 +1 @@
+<span overline="dotted">test</span>
diff --git a/tests/markups/fail-29.expected b/tests/markups/fail-29.expected
new file mode 100644
index 00000000..25ce2fe5
--- /dev/null
+++ b/tests/markups/fail-29.expected
@@ -0,0 +1 @@
+ERROR: Value of 'overline_color' attribute on <span> tag on line 1 could not be parsed; should be a color specification, not 'rgb(1,2,3)' \ No newline at end of file
diff --git a/tests/markups/fail-29.markup b/tests/markups/fail-29.markup
new file mode 100644
index 00000000..b94d60e8
--- /dev/null
+++ b/tests/markups/fail-29.markup
@@ -0,0 +1 @@
+<span overline-color="rgb(1,2,3)">test</span>
diff --git a/tests/markups/fail-30.expected b/tests/markups/fail-30.expected
new file mode 100644
index 00000000..e4b64e7d
--- /dev/null
+++ b/tests/markups/fail-30.expected
@@ -0,0 +1 @@
+ERROR: Value of 'size' attribute on <span> tag on line 1 could not be parsed; should be an integer, or a string such as 'small', not 'blue' \ No newline at end of file
diff --git a/tests/markups/fail-30.markup b/tests/markups/fail-30.markup
new file mode 100644
index 00000000..fc52cd23
--- /dev/null
+++ b/tests/markups/fail-30.markup
@@ -0,0 +1 @@
+<span size="blue">test</span>
diff --git a/tests/markups/fail-31.expected b/tests/markups/fail-31.expected
new file mode 100644
index 00000000..5b5f3045
--- /dev/null
+++ b/tests/markups/fail-31.expected
@@ -0,0 +1 @@
+ERROR: 'blue' is not a valid value for the 'gravity_hint' attribute on <span> tag, line 1; valid values are natural/strong/line \ No newline at end of file
diff --git a/tests/markups/fail-31.markup b/tests/markups/fail-31.markup
new file mode 100644
index 00000000..64316ff1
--- /dev/null
+++ b/tests/markups/fail-31.markup
@@ -0,0 +1 @@
+<span gravity-hint="blue">test</span>
diff --git a/tests/markups/fail-32.expected b/tests/markups/fail-32.expected
new file mode 100644
index 00000000..14e61e42
--- /dev/null
+++ b/tests/markups/fail-32.expected
@@ -0,0 +1 @@
+ERROR: Value of 'insert_hyphens' attribute on <span> tag line 1 should have one of 'true/yes/t/y' or 'false/no/f/n': 'blue' is not valid \ No newline at end of file
diff --git a/tests/markups/fail-32.markup b/tests/markups/fail-32.markup
new file mode 100644
index 00000000..9ec3c2b6
--- /dev/null
+++ b/tests/markups/fail-32.markup
@@ -0,0 +1 @@
+<span insert-hyphens="blue">test</span>
diff --git a/tests/markups/fail-33.expected b/tests/markups/fail-33.expected
new file mode 100644
index 00000000..f5c97686
--- /dev/null
+++ b/tests/markups/fail-33.expected
@@ -0,0 +1 @@
+ERROR: Value of 'allow_breaks' attribute on <span> tag line 1 should have one of 'true/yes/t/y' or 'false/no/f/n': 'blue' is not valid \ No newline at end of file
diff --git a/tests/markups/fail-33.markup b/tests/markups/fail-33.markup
new file mode 100644
index 00000000..783437b0
--- /dev/null
+++ b/tests/markups/fail-33.markup
@@ -0,0 +1 @@
+<span allow-breaks="blue">test</span>
diff --git a/tests/markups/fail-34.expected b/tests/markups/fail-34.expected
new file mode 100644
index 00000000..2f415718
--- /dev/null
+++ b/tests/markups/fail-34.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'boo' on line 1 char 14 \ No newline at end of file
diff --git a/tests/markups/fail-34.markup b/tests/markups/fail-34.markup
new file mode 100644
index 00000000..c081289b
--- /dev/null
+++ b/tests/markups/fail-34.markup
@@ -0,0 +1 @@
+<boo>test</boo>
diff --git a/tests/markups/fail-35.expected b/tests/markups/fail-35.expected
new file mode 100644
index 00000000..923cbdf7
--- /dev/null
+++ b/tests/markups/fail-35.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'ick' on line 1 char 14 \ No newline at end of file
diff --git a/tests/markups/fail-35.markup b/tests/markups/fail-35.markup
new file mode 100644
index 00000000..f379cf53
--- /dev/null
+++ b/tests/markups/fail-35.markup
@@ -0,0 +1 @@
+<ick>test</ick>
diff --git a/tests/markups/fail-36.expected b/tests/markups/fail-36.expected
new file mode 100644
index 00000000..08d5d8d9
--- /dev/null
+++ b/tests/markups/fail-36.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'moo' on line 1 char 14 \ No newline at end of file
diff --git a/tests/markups/fail-36.markup b/tests/markups/fail-36.markup
new file mode 100644
index 00000000..1b4e06c6
--- /dev/null
+++ b/tests/markups/fail-36.markup
@@ -0,0 +1 @@
+<moo>test</moo>
diff --git a/tests/markups/fail-37.expected b/tests/markups/fail-37.expected
new file mode 100644
index 00000000..bcd1acbc
--- /dev/null
+++ b/tests/markups/fail-37.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'su' on line 1 char 13 \ No newline at end of file
diff --git a/tests/markups/fail-37.markup b/tests/markups/fail-37.markup
new file mode 100644
index 00000000..695f113b
--- /dev/null
+++ b/tests/markups/fail-37.markup
@@ -0,0 +1 @@
+<su>test</su>
diff --git a/tests/markups/fail-38.expected b/tests/markups/fail-38.expected
new file mode 100644
index 00000000..fab88162
--- /dev/null
+++ b/tests/markups/fail-38.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'ugh' on line 1 char 14 \ No newline at end of file
diff --git a/tests/markups/fail-38.markup b/tests/markups/fail-38.markup
new file mode 100644
index 00000000..04f107cc
--- /dev/null
+++ b/tests/markups/fail-38.markup
@@ -0,0 +1 @@
+<ugh>test</ugh>
diff --git a/tests/markups/fail-39.expected b/tests/markups/fail-39.expected
new file mode 100644
index 00000000..2df26615
--- /dev/null
+++ b/tests/markups/fail-39.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'xtra' on line 1 char 15 \ No newline at end of file
diff --git a/tests/markups/fail-39.markup b/tests/markups/fail-39.markup
new file mode 100644
index 00000000..503dfb00
--- /dev/null
+++ b/tests/markups/fail-39.markup
@@ -0,0 +1 @@
+<xtra>test</xtra>
diff --git a/tests/markups/fail-6.expected b/tests/markups/fail-6.expected
new file mode 100644
index 00000000..4dbf45fd
--- /dev/null
+++ b/tests/markups/fail-6.expected
@@ -0,0 +1 @@
+ERROR: Unknown tag 'tag' on line 1 char 37 \ No newline at end of file
diff --git a/tests/markups/fail-6.markup b/tests/markups/fail-6.markup
new file mode 100644
index 00000000..b4435b0c
--- /dev/null
+++ b/tests/markups/fail-6.markup
@@ -0,0 +1 @@
+<span size="1024">this <tag>is bad</tag></span>
diff --git a/tests/markups/fail-7.expected b/tests/markups/fail-7.expected
new file mode 100644
index 00000000..c729fe64
--- /dev/null
+++ b/tests/markups/fail-7.expected
@@ -0,0 +1 @@
+ERROR: Attribute 'weight' occurs twice on <span> tag on line 1 char 44, may only occur once \ No newline at end of file
diff --git a/tests/markups/fail-7.markup b/tests/markups/fail-7.markup
new file mode 100644
index 00000000..04376b94
--- /dev/null
+++ b/tests/markups/fail-7.markup
@@ -0,0 +1 @@
+<span weight="bold" weight="black"> text</span>
diff --git a/tests/markups/fail-8.expected b/tests/markups/fail-8.expected
new file mode 100644
index 00000000..0a3d780e
--- /dev/null
+++ b/tests/markups/fail-8.expected
@@ -0,0 +1 @@
+ERROR: Tag 'b' does not support attribute 'attr' on line 1 char 31 \ No newline at end of file
diff --git a/tests/markups/fail-8.markup b/tests/markups/fail-8.markup
new file mode 100644
index 00000000..053da74a
--- /dev/null
+++ b/tests/markups/fail-8.markup
@@ -0,0 +1 @@
+<b attr="not allowed">test</b>
diff --git a/tests/markups/fail-9.expected b/tests/markups/fail-9.expected
new file mode 100644
index 00000000..a81ca513
--- /dev/null
+++ b/tests/markups/fail-9.expected
@@ -0,0 +1 @@
+ERROR: Value of 'strikethrough' attribute on <span> tag line 11 should have one of 'true/yes/t/y' or 'false/no/f/n': 'x' is not valid \ No newline at end of file
diff --git a/tests/markups/fail-9.markup b/tests/markups/fail-9.markup
new file mode 100644
index 00000000..c5d33342
--- /dev/null
+++ b/tests/markups/fail-9.markup
@@ -0,0 +1,11 @@
+<span font="Sans Italic 12"
+ foreground="#00ff00"
+ background="#f0f0f0"
+ underline="double"
+ underline_color="red"
+ strikethrough="x"
+ strikethrough_color="blue"
+ fallback="false"
+ lang="de"
+ gravity="south"
+ gravity_hint="strong">Lots of attrs</span>
diff --git a/tests/markups/valid-10.markup b/tests/markups/valid-10.markup
index b4540749..5bd94408 100644
--- a/tests/markups/valid-10.markup
+++ b/tests/markups/valid-10.markup
@@ -3,9 +3,9 @@
background="#f0f0f0"
underline="double"
underline_color="red"
- strikethrough="true"
+ strikethrough="yes"
strikethrough_color="blue"
- fallback="false"
+ fallback="no"
lang="de"
gravity="south"
gravity_hint="strong">Lots of attrs</span>
diff --git a/tests/markups/valid-11.markup b/tests/markups/valid-11.markup
index e7ae8388..6f5828fd 100644
--- a/tests/markups/valid-11.markup
+++ b/tests/markups/valid-11.markup
@@ -3,9 +3,9 @@
background="#f0f0f0"
underline="double"
underline_color="red"
- strikethrough="true"
+ strikethrough="t"
strikethrough_color="blue"
- fallback="false"
+ fallback="f"
lang="de"
gravity="south"
gravity_hint="strong">Lots <span font="bold">of</span> attrs</span>
diff --git a/tests/markups/valid-16.expected b/tests/markups/valid-16.expected
new file mode 100644
index 00000000..c8b000a8
--- /dev/null
+++ b/tests/markups/valid-16.expected
@@ -0,0 +1,27 @@
+larger and smaller and smaller now with base
+
+
+---
+
+range 0 11
+[0,44]scale=1.200000
+range 11 19
+[11,30]scale=1.000000
+range 19 30
+[19,30]scale=0.833333
+range 30 31
+[0,44]scale=1.200000
+range 31 44
+[0,44]scale=1.200000
+[31,44]size=15360
+range 44 2147483647
+
+
+---
+
+[0:11] (null) Normal 0
+[11:19] (null) Normal 0
+[19:30] (null) Normal 0
+[30:31] (null) Normal 0
+[31:44] (null) Normal 18
+[44:2147483647] (null) Normal 18
diff --git a/tests/markups/valid-16.markup b/tests/markups/valid-16.markup
new file mode 100644
index 00000000..c450c788
--- /dev/null
+++ b/tests/markups/valid-16.markup
@@ -0,0 +1 @@
+<span size="larger">larger and <span size="smaller">smaller <span size="smaller">and smaller</span></span> <span size="12800"><span size="larger">now with base</span></span></span>
diff --git a/tests/markups/valid-17.expected b/tests/markups/valid-17.expected
new file mode 100644
index 00000000..8b9ce039
--- /dev/null
+++ b/tests/markups/valid-17.expected
@@ -0,0 +1,14 @@
+test
+
+
+---
+
+range 0 4
+[0,4]show=3
+range 4 2147483647
+
+
+---
+
+[0:4] (null) Normal
+[4:2147483647] (null) Normal
diff --git a/tests/markups/valid-17.markup b/tests/markups/valid-17.markup
new file mode 100644
index 00000000..32302df8
--- /dev/null
+++ b/tests/markups/valid-17.markup
@@ -0,0 +1 @@
+<span show="spaces | line-breaks">test</span>
diff --git a/tests/markups/valid-18.expected b/tests/markups/valid-18.expected
new file mode 100644
index 00000000..6f372b15
--- /dev/null
+++ b/tests/markups/valid-18.expected
@@ -0,0 +1,24 @@
+Lots of attrs
+
+
+---
+
+range 0 13
+[0,13]font-desc=Sans Italic 12
+[0,13]foreground=#0000ffff0000
+[0,13]background=#f0f0f0f0f0f0
+[0,13]underline=2
+[0,13]underline-color=#ffff00000000
+[0,13]gravity=0
+[0,13]gravity-hint=1
+[0,13]strikethrough=1
+[0,13]strikethrough-color=#00000000ffff
+[0,13]fallback=0
+[0,13]language=de
+range 13 2147483647
+
+
+---
+
+[0:13] de Sans Italic 12
+[13:2147483647] (null) Sans Italic 12
diff --git a/tests/markups/valid-18.markup b/tests/markups/valid-18.markup
new file mode 100644
index 00000000..acc4fb51
--- /dev/null
+++ b/tests/markups/valid-18.markup
@@ -0,0 +1,11 @@
+<span font="Sans Italic 12"
+ foreground="#00ff00"
+ background="#f0f0f0"
+ underline="double"
+ underline_color="red"
+ strikethrough="y"
+ strikethrough_color="blue"
+ fallback="n"
+ lang="de"
+ gravity="south"
+ gravity_hint="strong">Lots of attrs</span>
diff --git a/tests/markups/valid-19.expected b/tests/markups/valid-19.expected
new file mode 100644
index 00000000..ea561c9d
--- /dev/null
+++ b/tests/markups/valid-19.expected
@@ -0,0 +1,18 @@
+test
+
+
+---
+
+range 0 4
+[0,4]family=Times
+[0,4]weight=700
+[0,4]foreground=#ffff00000000
+[0,4]letter-spacing=1024
+[0,4]insert-hyphens=1
+range 4 2147483647
+
+
+---
+
+[0:4] (null) Times Bold
+[4:2147483647] (null) Times Bold
diff --git a/tests/markups/valid-19.markup b/tests/markups/valid-19.markup
new file mode 100644
index 00000000..f2941cef
--- /dev/null
+++ b/tests/markups/valid-19.markup
@@ -0,0 +1,5 @@
+<span face="Times"
+ weight="bold"
+ insert_hyphens="true"
+ letter_spacing="1024"
+ color="red">test</span>
diff --git a/tests/markups/valid-2.expected b/tests/markups/valid-2.expected
index 6ad9a22a..c372666a 100644
--- a/tests/markups/valid-2.expected
+++ b/tests/markups/valid-2.expected
@@ -4,7 +4,7 @@ Blue text is cool!
---
range 0 9
-[0,9]scale=1.440000
+[0,9]scale=1.728000
[0,9]foreground=#00000000ffff
range 9 13
range 13 17
diff --git a/tests/markups/valid-2.markup b/tests/markups/valid-2.markup
index 3e4136f1..a08c89fe 100644
--- a/tests/markups/valid-2.markup
+++ b/tests/markups/valid-2.markup
@@ -1 +1 @@
-<span foreground="blue" size="x-large">Blue text</span> is <span style="italic">cool</span>!
+<span foreground="blue" size="xx-large">Blue text</span> is <span style="italic">cool</span>!
diff --git a/tests/markups/valid-3.expected b/tests/markups/valid-3.expected
index 6f372b15..3b69c218 100644
--- a/tests/markups/valid-3.expected
+++ b/tests/markups/valid-3.expected
@@ -15,6 +15,7 @@ range 0 13
[0,13]strikethrough-color=#00000000ffff
[0,13]fallback=0
[0,13]language=de
+[0,13]allow-breaks=1
range 13 2147483647
diff --git a/tests/markups/valid-3.markup b/tests/markups/valid-3.markup
index c2f7ab86..a17409b0 100644
--- a/tests/markups/valid-3.markup
+++ b/tests/markups/valid-3.markup
@@ -6,6 +6,7 @@
strikethrough="true"
strikethrough_color="blue"
fallback="false"
+ allow_breaks="true"
lang="de"
gravity="south"
gravity_hint="strong">Lots of attrs</span>
diff --git a/tests/markups/valid-8.expected b/tests/markups/valid-8.expected
index 4f16487f..79a0f01d 100644
--- a/tests/markups/valid-8.expected
+++ b/tests/markups/valid-8.expected
@@ -2,35 +2,84 @@ Text
Text
Text
Text
+Text
+Text
+Text
+Text
+Text
---
range 0 4
+[0,4]scale=0.578704
+[0,4]variant=0
+[0,4]stretch=0
[0,4]foreground=#00000000ffff
[0,4]foreground-alpha=65535
range 4 5
range 5 9
+[5,9]scale=0.694444
+[5,9]variant=1
+[5,9]stretch=1
[5,9]foreground=#00000000ffff
[5,9]foreground-alpha=32767
range 9 10
range 10 14
+[10,14]scale=0.833333
+[10,14]stretch=2
[10,14]background=#00000000ffff
[10,14]background-alpha=1
range 14 15
range 15 19
+[15,19]scale=1.000000
+[15,19]stretch=3
[15,19]background=#00000000ffff
[15,19]background-alpha=21626
-range 19 2147483647
+range 19 20
+range 20 24
+[20,24]scale=1.200000
+[20,24]stretch=4
+[20,24]background=#00000000ffff
+[20,24]background-alpha=21626
+range 24 25
+range 25 29
+[25,29]scale=1.440000
+[25,29]stretch=5
+[25,29]background=#00000000ffff
+[25,29]background-alpha=43690
+range 29 30
+range 30 34
+[30,34]scale=1.728000
+[30,34]stretch=6
+range 34 35
+range 35 39
+[35,39]scale=1.728000
+[35,39]stretch=7
+range 39 40
+range 40 44
+[40,44]scale=1.728000
+[40,44]stretch=8
+range 44 2147483647
---
-[0:4] (null) Normal
-[4:5] (null) Normal
-[5:9] (null) Normal
-[9:10] (null) Normal
-[10:14] (null) Normal
-[14:15] (null) Normal
-[15:19] (null) Normal
-[19:2147483647] (null) Normal
+[0:4] (null) Ultra-Condensed 0
+[4:5] (null) Ultra-Condensed 0
+[5:9] (null) Extra-Condensed Small-Caps 0
+[9:10] (null) Extra-Condensed Small-Caps 0
+[10:14] (null) Condensed Small-Caps 0
+[14:15] (null) Condensed Small-Caps 0
+[15:19] (null) Semi-Condensed Small-Caps 0
+[19:20] (null) Semi-Condensed Small-Caps 0
+[20:24] (null) Small-Caps 0
+[24:25] (null) Small-Caps 0
+[25:29] (null) Semi-Expanded Small-Caps 0
+[29:30] (null) Semi-Expanded Small-Caps 0
+[30:34] (null) Expanded Small-Caps 0
+[34:35] (null) Expanded Small-Caps 0
+[35:39] (null) Extra-Expanded Small-Caps 0
+[39:40] (null) Extra-Expanded Small-Caps 0
+[40:44] (null) Ultra-Expanded Small-Caps 0
+[44:2147483647] (null) Ultra-Expanded Small-Caps 0
diff --git a/tests/markups/valid-8.markup b/tests/markups/valid-8.markup
index 91e9aca7..d314ed16 100644
--- a/tests/markups/valid-8.markup
+++ b/tests/markups/valid-8.markup
@@ -1,4 +1,9 @@
-<span foreground="blue" alpha="65535">Text</span>
-<span foreground="blue" fgalpha="50%">Text</span>
-<span background="blue" background_alpha="1">Text</span>
-<span background="blue" bgalpha="33%">Text</span>
+<span foreground="blue" alpha="65535" size="xx-small" variant="normal" stretch="ultracondensed">Text</span>
+<span fgcolor="blue" fgalpha="50%" size="x-small" font_variant="smallcaps" font_stretch="extracondensed">Text</span>
+<span background="blue" background_alpha="1" size="small" stretch="condensed">Text</span>
+<span bgcolor="blue" bgalpha="33%" size="medium" stretch="semicondensed">Text</span>
+<span background="blue" bgalpha="33%" font_size="large" stretch="normal">Text</span>
+<span background="#0000ffaa" font_size="x-large" stretch="semiexpanded">Text</span>
+<span font_size="xx-large" stretch="expanded">Text</span>
+<span font_size="xx-large" stretch="extraexpanded">Text</span>
+<span font_size="xx-large" stretch="ultraexpanded">Text</span>
diff --git a/tests/meson.build b/tests/meson.build
index ccd2541e..3e9d8075 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -22,7 +22,10 @@ tests = [
[ 'testboundaries' ],
[ 'testboundaries_ucd' ],
[ 'testcolor' ],
- [ 'testscript' ]
+ [ 'testscript' ],
+ [ 'testlanguage' ],
+ [ 'testmatrix' ],
+ [ 'testtabs' ],
]
if build_pangoft2
@@ -35,6 +38,7 @@ endif
if cairo_dep.found()
test_cflags += '-DHAVE_CAIRO'
tests += [
+ [ 'testcontext', [ 'testcontext.c' ], [ libpangocairo_dep ] ],
[ 'testiter', [ 'testiter.c' ], [ libpangocairo_dep ] ],
[ 'test-ellipsize', [ 'test-ellipsize.c' ], [ libpangocairo_dep ] ],
[ 'markup-parse', [ 'markup-parse.c' , 'test-common.c' ], [ libpangocairo_dep ] ],
@@ -79,6 +83,39 @@ test_markups_data = [
'markups/fail-3',
'markups/fail-4',
'markups/fail-5',
+ 'markups/fail-6',
+ 'markups/fail-7',
+ 'markups/fail-8',
+ 'markups/fail-9',
+ 'markups/fail-10',
+ 'markups/fail-11',
+ 'markups/fail-12',
+ 'markups/fail-13',
+ 'markups/fail-14',
+ 'markups/fail-15',
+ 'markups/fail-16',
+ 'markups/fail-17',
+ 'markups/fail-19',
+ 'markups/fail-20',
+ 'markups/fail-21',
+ 'markups/fail-22',
+ 'markups/fail-23',
+ 'markups/fail-24',
+ 'markups/fail-25',
+ 'markups/fail-26',
+ 'markups/fail-27',
+ 'markups/fail-28',
+ 'markups/fail-29',
+ 'markups/fail-30',
+ 'markups/fail-31',
+ 'markups/fail-32',
+ 'markups/fail-33',
+ 'markups/fail-34',
+ 'markups/fail-35',
+ 'markups/fail-36',
+ 'markups/fail-37',
+ 'markups/fail-38',
+ 'markups/fail-39',
'markups/valid-1',
'markups/valid-2',
'markups/valid-3',
@@ -94,6 +131,10 @@ test_markups_data = [
'markups/valid-13',
'markups/valid-14',
'markups/valid-15',
+ 'markups/valid-16',
+ 'markups/valid-17',
+ 'markups/valid-18',
+ 'markups/valid-19',
]
test_breaks_data = [
diff --git a/tests/test-common.c b/tests/test-common.c
index 514058cc..a6339415 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -81,6 +81,25 @@ done:
return diff;
}
+gboolean
+file_has_prefix (const char *filename,
+ const char *str,
+ GError **error)
+{
+ char *contents;
+ gsize len;
+ gboolean ret;
+
+ if (!g_file_get_contents (filename, &contents, &len, error))
+ return FALSE;
+
+ ret = g_str_has_prefix (contents, str);
+
+ g_free (contents);
+
+ return ret;
+}
+
void
print_attribute (PangoAttribute *attr, GString *string)
{
@@ -201,6 +220,204 @@ print_attributes (GSList *attrs, GString *string)
}
}
+static PangoAttribute *
+attribute_from_string (const char *string)
+{
+ char *s, *p;
+ PangoAttribute *attr;
+ long start, end;
+ GEnumClass *class;
+ int i;
+ PangoColor color;
+
+ s = string;
+ g_assert (*s == '[');
+
+ s++;
+ start = strtol (s, &p, 10);
+ g_assert (p > s);
+ g_assert (*p == ',');
+ s = p + 1;
+
+ g_assert (start >= 0);
+
+ end = strtol (s, &p, 10);
+ g_assert (p > s);
+ g_assert (*p == ']');
+ s = p + 1;
+
+ if (end == -1)
+ end = G_MAXUINT;
+
+ g_assert (start >= 0);
+ g_assert (end >= 0);
+
+ class = g_type_class_ref (pango_attr_type_get_type ());
+
+ for (i = 0; i < class->n_values; i++)
+ {
+ if (g_str_has_prefix (s, class->values[i].value_nick))
+ break;
+ }
+
+ g_assert (i < class->n_values);
+
+ s += strlen (class->values[i].value_nick);
+ g_assert (*s == '=');
+ s++;
+
+ switch (class->values[i].value)
+ {
+ case PANGO_ATTR_LANGUAGE:
+ attr = pango_attr_language_new (pango_language_from_string (s));
+ break;
+ case PANGO_ATTR_FAMILY:
+ attr = pango_attr_family_new (s);
+ break;
+ case PANGO_ATTR_FONT_FEATURES:
+ attr = pango_attr_font_features_new (s);
+ break;
+ case PANGO_ATTR_STYLE:
+ attr = pango_attr_style_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_WEIGHT:
+ attr = pango_attr_weight_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_VARIANT:
+ attr = pango_attr_variant_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_STRETCH:
+ attr = pango_attr_stretch_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_SIZE:
+ attr = pango_attr_size_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ attr = pango_attr_size_new_absolute (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_UNDERLINE:
+ attr = pango_attr_underline_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_OVERLINE:
+ attr = pango_attr_overline_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_STRIKETHROUGH:
+ attr = pango_attr_strikethrough_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_RISE:
+ attr = pango_attr_rise_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_FALLBACK:
+ attr = pango_attr_fallback_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_LETTER_SPACING:
+ attr = pango_attr_letter_spacing_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_GRAVITY:
+ attr = pango_attr_gravity_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_GRAVITY_HINT:
+ attr = pango_attr_gravity_hint_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_FOREGROUND_ALPHA:
+ attr = pango_attr_foreground_alpha_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_BACKGROUND_ALPHA:
+ attr = pango_attr_background_alpha_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_ALLOW_BREAKS:
+ attr = pango_attr_allow_breaks_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_INSERT_HYPHENS:
+ attr = pango_attr_insert_hyphens_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_SHOW:
+ attr = pango_attr_show_new (strtol (s, &p, 10));
+ break;
+ case PANGO_ATTR_FONT_DESC:
+ {
+ PangoFontDescription *desc = pango_font_description_from_string (s);
+ attr = pango_attr_font_desc_new (desc);
+ pango_font_description_free (desc);
+ }
+ break;
+ case PANGO_ATTR_FOREGROUND:
+ {
+ pango_color_parse (&color, s);
+ attr = pango_attr_foreground_new (color.red, color.green, color.blue);
+ }
+ break;
+ case PANGO_ATTR_BACKGROUND:
+ {
+ pango_color_parse (&color, s);
+ attr = pango_attr_background_new (color.red, color.green, color.blue);
+ }
+ break;
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ {
+ pango_color_parse (&color, s);
+ attr = pango_attr_underline_color_new (color.red, color.green, color.blue);
+ }
+ break;
+ case PANGO_ATTR_OVERLINE_COLOR:
+ {
+ pango_color_parse (&color, s);
+ attr = pango_attr_overline_color_new (color.red, color.green, color.blue);
+ }
+ break;
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ {
+ pango_color_parse (&color, s);
+ attr = pango_attr_strikethrough_color_new (color.red, color.green, color.blue);
+ }
+ break;
+ case PANGO_ATTR_SHAPE:
+ {
+ PangoRectangle rect = { 0, };
+ attr = pango_attr_shape_new (&rect, &rect);
+ }
+ break;
+ case PANGO_ATTR_SCALE:
+ attr = pango_attr_scale_new (strtod (s, &p));
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_type_class_unref (class);
+
+ attr->start_index = start;
+ attr->end_index = end;
+
+ return attr;
+}
+
+PangoAttrList *
+attributes_from_string (const char *string)
+{
+ PangoAttrList *attrs;
+ char **lines;
+
+ attrs = pango_attr_list_new ();
+
+ lines = g_strsplit (string, "\n", 0);
+ for (int i = 0; lines[i]; i++)
+ {
+ PangoAttribute *attr;
+
+ if (lines[i][0] == '\0')
+ continue;
+
+ attr = attribute_from_string (lines[i]);
+ g_assert (attr);
+ pango_attr_list_insert (attrs, attr);
+ }
+ g_strfreev (lines);
+
+ return attrs;
+}
+
const char *
get_script_name (GUnicodeScript s)
{
diff --git a/tests/test-common.h b/tests/test-common.h
index 28a850ae..22953f2d 100644
--- a/tests/test-common.h
+++ b/tests/test-common.h
@@ -6,6 +6,10 @@ char * diff_with_file (const char *file,
gssize len,
GError **error);
+gboolean file_has_prefix (const char *file,
+ const char *str,
+ GError **error);
+
void print_attribute (PangoAttribute *attr,
GString *string);
@@ -15,6 +19,9 @@ void print_attributes (GSList *attrs,
void print_attr_list (PangoAttrList *attrs,
GString *string);
+PangoAttrList *
+attributes_from_string (const char *string);
+
const char *get_script_name (GUnicodeScript s);
diff --git a/tests/test-font.c b/tests/test-font.c
index aecf32c8..e2147485 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <locale.h>
+#include <gio/gio.h>
#include <pango/pangocairo.h>
static PangoContext *context;
@@ -314,6 +315,73 @@ test_roundtrip_emoji (void)
g_object_unref (context);
}
+static void
+test_font_models (void)
+{
+ PangoFontMap *map = pango_cairo_font_map_get_default ();
+
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (map)) == PANGO_TYPE_FONT_FAMILY);
+
+ for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (map)); i++)
+ {
+ GObject *obj = g_list_model_get_item (G_LIST_MODEL (map), i);
+
+ g_assert_true (PANGO_IS_FONT_FAMILY (obj));
+
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (obj)) == PANGO_TYPE_FONT_FACE);
+
+ if (g_ascii_strcasecmp (pango_font_family_get_name (PANGO_FONT_FAMILY (obj)), "monospace") == 0)
+ {
+ g_assert_true (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)));
+ }
+
+ for (guint j = 0; j < g_list_model_get_n_items (G_LIST_MODEL (obj)); j++)
+ {
+ GObject *obj2 = g_list_model_get_item (G_LIST_MODEL (obj), j);
+ int *sizes;
+ int n_sizes;
+
+ g_assert_true (PANGO_IS_FONT_FACE (obj2));
+
+ g_assert_true (pango_font_face_get_family (PANGO_FONT_FACE (obj2)) == (PangoFontFamily *)obj);
+
+ pango_font_face_list_sizes (PANGO_FONT_FACE (obj2), &sizes, &n_sizes);
+ /* no more bitmap fonts */
+ g_assert_null (sizes);
+ g_assert_cmpint (n_sizes, ==, 0);
+
+ g_object_unref (obj2);
+ }
+
+ g_object_unref (obj);
+ }
+}
+
+static void
+test_glyph_extents (void)
+{
+ PangoRectangle ink, logical;
+
+ pango_font_get_glyph_extents (NULL, 0, &ink, &logical);
+ g_assert_cmpint (ink.height, ==, (PANGO_UNKNOWN_GLYPH_HEIGHT - 2) * PANGO_SCALE);
+ g_assert_cmpint (ink.width, ==, (PANGO_UNKNOWN_GLYPH_WIDTH - 2) * PANGO_SCALE);
+ g_assert_cmpint (logical.height, ==, PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE);
+ g_assert_cmpint (logical.width, ==, PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE);
+}
+
+static void
+test_font_metrics (void)
+{
+ PangoFontMetrics *metrics;
+
+ metrics = pango_font_get_metrics (NULL, NULL);
+
+ g_assert_cmpint (metrics->approximate_char_width, ==, PANGO_SCALE * PANGO_UNKNOWN_GLYPH_WIDTH);
+ g_assert_cmpint (metrics->approximate_digit_width, ==, PANGO_SCALE * PANGO_UNKNOWN_GLYPH_WIDTH);
+
+ pango_font_metrics_unref (metrics);
+}
+
int
main (int argc, char *argv[])
{
@@ -332,6 +400,9 @@ main (int argc, char *argv[])
g_test_add_func ("/pango/font/enumerate", test_enumerate);
g_test_add_func ("/pango/font/roundtrip/plain", test_roundtrip_plain);
g_test_add_func ("/pango/font/roundtrip/emoji", test_roundtrip_emoji);
+ g_test_add_func ("/pango/font/models", test_font_models);
+ g_test_add_func ("/pango/font/glyph-extents", test_glyph_extents);
+ g_test_add_func ("/pango/font/font-metrics", test_font_metrics);
return g_test_run ();
}
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 66d149cd..26277b56 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -92,6 +92,25 @@ test_attributes_equal (void)
}
static void
+test_attributes_register (void)
+{
+ PangoAttrType type;
+ GEnumClass *class;
+
+ type = pango_attr_type_register ("my-attribute");
+ g_assert_cmpstr (pango_attr_type_get_name (type), ==, "my-attribute");
+
+ class = g_type_class_ref (PANGO_TYPE_ATTR_TYPE);
+ for (int i = 0; i < class->n_values; i++)
+ {
+ g_assert_cmpint (type, !=, class->values[i].value);
+ g_assert_null (pango_attr_type_get_name (class->values[i].value));
+ }
+
+ g_type_class_unref (class);
+}
+
+static void
assert_attributes (GSList *attrs,
const char *expected)
{
@@ -133,7 +152,7 @@ assert_attr_iterator (PangoAttrIterator *iter,
static void
test_list (void)
{
- PangoAttrList *list;
+ PangoAttrList *list, *list2;
PangoAttribute *attr;
list = pango_attr_list_new ();
@@ -145,6 +164,12 @@ test_list (void)
attr = pango_attr_size_new (30);
pango_attr_list_insert (list, attr);
+ list2 = attributes_from_string ("[0,-1]size=10\n"
+ "[0,-1]size=20\n"
+ "[0,-1]size=30\n");
+ g_assert_true (pango_attr_list_equal (list, list2));
+ pango_attr_list_unref (list2);
+
assert_attr_list (list, "[0,-1]size=10\n"
"[0,-1]size=20\n"
"[0,-1]size=30\n");
@@ -179,20 +204,15 @@ test_list_change (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = pango_attr_list_new ();
+ list = attributes_from_string ("[0,10]size=10\n"
+ "[0,30]weight=700\n"
+ "[20,30]size=20\n");
- attr = pango_attr_size_new (10);
- attr->start_index = 0;
+ /* no-op */
+ attr = pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS);
+ attr->start_index = 10;
attr->end_index = 10;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_size_new (20);
- attr->start_index = 20;
- attr->end_index = 30;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = 0;
- attr->end_index = 30;
- pango_attr_list_insert (list, attr);
+ pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]size=10\n"
"[0,30]weight=700\n"
@@ -244,25 +264,10 @@ test_list_splice (void)
PangoAttrList *base;
PangoAttrList *list;
PangoAttrList *other;
- PangoAttribute *attr;
-
- base = pango_attr_list_new ();
- attr = pango_attr_size_new (10);
- attr->start_index = 0;
- attr->end_index = -1;
- pango_attr_list_insert (base, attr);
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = 10;
- attr->end_index = 15;
- pango_attr_list_insert (base, attr);
- attr = pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS);
- attr->start_index = 20;
- attr->end_index = 30;
- pango_attr_list_insert (base, attr);
- assert_attr_list (base, "[0,-1]size=10\n"
- "[10,15]weight=700\n"
- "[20,30]variant=1\n");
+ base = attributes_from_string ("[0,-1]size=10\n"
+ "[10,15]weight=700\n"
+ "[20,30]variant=1\n");
/* splice in an empty list */
list = pango_attr_list_copy (base);
@@ -278,15 +283,9 @@ test_list_splice (void)
/* splice in some attributes */
list = pango_attr_list_copy (base);
- other = pango_attr_list_new ();
- attr = pango_attr_size_new (20);
- attr->start_index = 0;
- attr->end_index = 3;
- pango_attr_list_insert (other, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 2;
- attr->end_index = 4;
- pango_attr_list_insert (other, attr);
+
+ other = attributes_from_string ("[0,3]size=20\n"
+ "[2,4]stretch=2\n");
pango_attr_list_splice (list, other, 11, 5);
@@ -344,23 +343,9 @@ test_list_splice3 (void)
{
PangoAttrList *list;
PangoAttrList *other;
- PangoAttribute *attr;
- list = pango_attr_list_new ();
- other = pango_attr_list_new ();
-
- attr = pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS);
- attr->start_index = 10;
- attr->end_index = 30;
- pango_attr_list_insert (list, attr);
-
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
- attr->end_index = PANGO_ATTR_INDEX_TO_TEXT_END;
- pango_attr_list_insert (other, attr);
-
- assert_attr_list (list, "[10,30]variant=1\n");
- assert_attr_list (other, "[0,-1]weight=700\n");
+ list = attributes_from_string ("[10,30]variant=1\n");
+ other = attributes_from_string ("[0,-1]weight=700\n");
pango_attr_list_splice (list, other, 20, 5);
@@ -391,22 +376,10 @@ test_list_filter (void)
{
PangoAttrList *list;
PangoAttrList *out;
- PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_size_new (10);
- pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 10;
- attr->end_index = 20;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = 20;
- pango_attr_list_insert (list, attr);
-
- assert_attr_list (list, "[0,-1]size=10\n"
- "[10,20]stretch=2\n"
- "[20,-1]weight=700\n");
+ list = attributes_from_string ("[0,-1]size=10\n"
+ "[10,20]stretch=2\n"
+ "[20,-1]weight=700\n");
out = pango_attr_list_filter (list, never_true, NULL);
g_assert_null (out);
@@ -541,6 +514,10 @@ test_iter_get_font (void)
attr->start_index = 10;
attr->end_index = 30;
pango_attr_list_insert (list, attr);
+ attr = pango_attr_size_new_absolute (10 * PANGO_SCALE);
+ attr->start_index = 10;
+ attr->end_index = 20;
+ pango_attr_list_insert (list, attr);
attr = pango_attr_language_new (pango_language_from_string ("ja-JP"));
attr->start_index = 10;
attr->end_index = 20;
@@ -565,7 +542,7 @@ test_iter_get_font (void)
pango_attr_iterator_next (iter);
desc = pango_font_description_new ();
pango_attr_iterator_get_font (iter, desc, &lang, &attrs);
- desc2 = pango_font_description_from_string ("Times Condensed 10");
+ desc2 = pango_font_description_from_string ("Times Condensed 10px");
g_assert_true (pango_font_description_equal (desc, desc2));
g_assert_nonnull (lang);
g_assert_cmpstr (pango_language_to_string (lang), ==, "ja-jp");
@@ -651,35 +628,12 @@ static void
test_list_update (void)
{
PangoAttrList *list;
- PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 10;
- attr->end_index = 11;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 0;
- attr->end_index = 200;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
- attr->start_index = 5;
- attr->end_index = 15;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 11;
- attr->end_index = 100;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 30;
- attr->end_index = 60;
- pango_attr_list_insert (list, attr);
-
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ list = attributes_from_string ("[0,200]rise=100\n"
+ "[5,15]family=Times\n"
+ "[10,11]size=10240\n"
+ "[11,100]fallback=0\n"
+ "[30,60]stretch=2\n");
pango_attr_list_update (list, 8, 10, 20);
@@ -705,6 +659,20 @@ test_list_update2 (void)
pango_attr_list_unref (list);
}
+/* test overflow */
+static void
+test_list_update3 (void)
+{
+ PangoAttrList *list;
+
+ list = attributes_from_string ("[5,4294967285]family=Times\n");
+
+ pango_attr_list_update (list, 8, 10, 30);
+
+ assert_attr_list (list, "[5,-1]family=Times\n");
+
+ pango_attr_list_unref (list);
+}
static void
test_list_equal (void)
{
@@ -787,33 +755,11 @@ test_insert (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 10;
- attr->end_index = 11;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 0;
- attr->end_index = 200;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
- attr->start_index = 5;
- attr->end_index = 15;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 11;
- attr->end_index = 100;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 30;
- attr->end_index = 60;
- pango_attr_list_insert (list, attr);
-
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ list = attributes_from_string ("[0,200]rise=100\n"
+ "[5,15]family=Times\n"
+ "[10,11]size=10240\n"
+ "[11,100]fallback=0\n"
+ "[30,60]stretch=2\n");
attr = pango_attr_family_new ("Times");
attr->start_index = 10;
@@ -847,43 +793,13 @@ test_insert2 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 10;
- attr->end_index = 11;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 0;
- attr->end_index = 200;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
- attr->start_index = 5;
- attr->end_index = 15;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
- attr->start_index = 20;
- attr->end_index = 30;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Futura");
- attr->start_index = 30;
- attr->end_index = 40;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 11;
- attr->end_index = 100;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 30;
- attr->end_index = 60;
- pango_attr_list_insert (list, attr);
-
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[20,30]family=Times\n"
- "[30,40]family=Futura\n"
- "[30,60]stretch=2\n");
+ list = attributes_from_string ("[0,200]rise=100\n"
+ "[5,15]family=Times\n"
+ "[10,11]size=10240\n"
+ "[11,100]fallback=0\n"
+ "[20,30]family=Times\n"
+ "[30,40]family=Futura\n"
+ "[30,60]stretch=2\n");
attr = pango_attr_family_new ("Times");
attr->start_index = 10;
@@ -914,53 +830,16 @@ test_merge (void)
{
PangoAttrList *list;
PangoAttrList *list2;
- PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 10;
- attr->end_index = 11;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 0;
- attr->end_index = 200;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
- attr->start_index = 5;
- attr->end_index = 15;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 11;
- attr->end_index = 100;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 30;
- attr->end_index = 60;
- pango_attr_list_insert (list, attr);
+ list = attributes_from_string ("[0,200]rise=100\n"
+ "[5,15]family=Times\n"
+ "[10,11]size=10240\n"
+ "[11,100]fallback=0\n"
+ "[30,60]stretch=2\n");
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
-
- list2 = pango_attr_list_new ();
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 11;
- attr->end_index = 13;
- pango_attr_list_insert (list2, attr);
- attr = pango_attr_size_new (11 * PANGO_SCALE);
- attr->start_index = 13;
- attr->end_index = 15;
- pango_attr_list_insert (list2, attr);
- attr = pango_attr_size_new (12 * PANGO_SCALE);
- attr->start_index = 40;
- attr->end_index = 50;
- pango_attr_list_insert (list2, attr);
-
- assert_attr_list (list2, "[11,13]size=10240\n"
- "[13,15]size=11264\n"
- "[40,50]size=12288\n");
+ list2 = attributes_from_string ("[11,13]size=10240\n"
+ "[13,15]size=11264\n"
+ "[40,50]size=12288\n");
pango_attr_list_filter (list2, attr_list_merge_filter, list);
@@ -985,18 +864,8 @@ test_merge2 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = pango_attr_list_new ();
- attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
- attr->start_index = 0;
- attr->end_index = 10;
- pango_attr_list_insert (list, attr);
- attr = pango_attr_foreground_new (0, 0, 0xffff);
- attr->start_index = 0;
- attr->end_index = 10;
- pango_attr_list_insert (list, attr);
-
- assert_attr_list (list, "[0,10]underline=1\n"
- "[0,10]foreground=#00000000ffff\n");
+ list = attributes_from_string ("[0,10]underline=1\n"
+ "[0,10]foreground=#00000000ffff\n");
attr = pango_attr_foreground_new (0xffff, 0, 0);
attr->start_index = 2;
@@ -1131,6 +1000,7 @@ main (int argc, char *argv[])
g_test_add_func ("/attributes/basic", test_attributes_basic);
g_test_add_func ("/attributes/equal", test_attributes_equal);
+ g_test_add_func ("/attributes/register", test_attributes_register);
g_test_add_func ("/attributes/list/basic", test_list);
g_test_add_func ("/attributes/list/change", test_list_change);
g_test_add_func ("/attributes/list/splice", test_list_splice);
@@ -1139,6 +1009,7 @@ main (int argc, char *argv[])
g_test_add_func ("/attributes/list/filter", test_list_filter);
g_test_add_func ("/attributes/list/update", test_list_update);
g_test_add_func ("/attributes/list/update2", test_list_update2);
+ g_test_add_func ("/attributes/list/update3", test_list_update3);
g_test_add_func ("/attributes/list/equal", test_list_equal);
g_test_add_func ("/attributes/list/insert", test_insert);
g_test_add_func ("/attributes/list/insert2", test_insert2);
diff --git a/tests/testcolor.c b/tests/testcolor.c
index 62bbe4bf..b32eb6ee 100644
--- a/tests/testcolor.c
+++ b/tests/testcolor.c
@@ -122,12 +122,42 @@ test_color (void)
test_one_color (spec);
}
+static void
+test_color_copy (void)
+{
+ PangoColor orig = { 0, 200, 5000 };
+ PangoColor *copy;
+
+ copy = pango_color_copy (&orig);
+
+ g_assert_cmpint (orig.red, ==, copy->red);
+ g_assert_cmpint (orig.green, ==, copy->green);
+ g_assert_cmpint (orig.blue, ==, copy->blue);
+
+ pango_color_free (copy);
+}
+
+static void
+test_color_serialize (void)
+{
+ PangoColor orig = { 0, 200, 5000 };
+ char *string;
+
+ string = pango_color_to_string (&orig);
+
+ g_assert_cmpstr (string, ==, "#000000c81388");
+
+ g_free (string);
+}
+
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/color/parse", test_color);
+ g_test_add_func ("/color/copy", test_color_copy);
+ g_test_add_func ("/color/serialize", test_color_serialize);
return g_test_run ();
}
diff --git a/tests/testcontext.c b/tests/testcontext.c
new file mode 100644
index 00000000..9cd8d833
--- /dev/null
+++ b/tests/testcontext.c
@@ -0,0 +1,145 @@
+/* Pango
+ * testcontext.c: Test program for PangoContext
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <pango/pango.h>
+#include <pango/pangocairo.h>
+
+static void
+test_list_families (void)
+{
+ PangoContext *context;
+ PangoFontFamily **families = NULL;
+ int n_families = 0;
+
+ context = pango_context_new ();
+
+ pango_context_list_families (context, &families, &n_families);
+ g_assert_null (families);
+ g_assert_cmpint (n_families, ==, 0);
+
+ pango_context_set_font_map (context, pango_cairo_font_map_get_default ());
+
+ pango_context_list_families (context, &families, &n_families);
+ g_assert_nonnull (families);
+ g_assert_cmpint (n_families, >, 0);
+
+ g_free (families);
+
+ g_object_unref (context);
+}
+
+static void
+test_set_language (void)
+{
+ PangoContext *context;
+
+ context = pango_context_new ();
+
+ pango_context_set_language (context, pango_language_from_string ("de-de"));
+ g_assert_true (pango_context_get_language (context) == pango_language_from_string ("de-de"));
+
+ pango_context_set_language (context, NULL);
+ g_assert_null (pango_context_get_language (context));
+
+ g_object_unref (context);
+}
+
+static void
+test_set_base_dir (void)
+{
+ PangoContext *context;
+
+ context = pango_context_new ();
+
+ pango_context_set_base_dir (context, PANGO_DIRECTION_RTL);
+ g_assert_true (pango_context_get_base_dir (context) == PANGO_DIRECTION_RTL);
+
+ pango_context_set_base_dir (context, PANGO_DIRECTION_WEAK_LTR);
+ g_assert_true (pango_context_get_base_dir (context) == PANGO_DIRECTION_WEAK_LTR);
+
+ g_object_unref (context);
+}
+
+static void
+test_set_base_gravity (void)
+{
+ PangoContext *context;
+
+ context = pango_context_new ();
+
+ pango_context_set_base_gravity (context, PANGO_GRAVITY_SOUTH);
+ g_assert_true (pango_context_get_base_gravity (context) == PANGO_GRAVITY_SOUTH);
+ g_assert_true (pango_context_get_gravity (context) == PANGO_GRAVITY_SOUTH);
+
+ pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO);
+ g_assert_true (pango_context_get_base_gravity (context) == PANGO_GRAVITY_AUTO);
+ g_assert_true (pango_context_get_gravity (context) == PANGO_GRAVITY_SOUTH);
+
+ g_object_unref (context);
+}
+
+static void
+test_set_gravity_hint (void)
+{
+ PangoContext *context;
+
+ context = pango_context_new ();
+
+ pango_context_set_gravity_hint (context, PANGO_GRAVITY_HINT_NATURAL);
+ g_assert_true (pango_context_get_gravity_hint (context) == PANGO_GRAVITY_HINT_NATURAL);
+
+ pango_context_set_gravity_hint (context, PANGO_GRAVITY_HINT_STRONG);
+ g_assert_true (pango_context_get_gravity_hint (context) == PANGO_GRAVITY_HINT_STRONG);
+
+ g_object_unref (context);
+}
+
+static void
+test_set_round_glyph_positions (void)
+{
+ PangoContext *context;
+
+ context = pango_context_new ();
+
+ pango_context_set_round_glyph_positions (context, TRUE);
+ g_assert_true (pango_context_get_round_glyph_positions (context));
+
+ pango_context_set_round_glyph_positions (context, FALSE);
+ g_assert_false (pango_context_get_round_glyph_positions (context));
+
+ g_object_unref (context);
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/context/list-families", test_list_families);
+ g_test_add_func ("/context/set-language", test_set_language);
+ g_test_add_func ("/context/set-base-dir", test_set_base_dir);
+ g_test_add_func ("/context/set-base-gravity", test_set_base_gravity);
+ g_test_add_func ("/context/set-gravity-hint", test_set_gravity_hint);
+ g_test_add_func ("/context/set-round-glyph-positions", test_set_round_glyph_positions);
+
+ return g_test_run ();
+}
diff --git a/tests/testlanguage.c b/tests/testlanguage.c
new file mode 100644
index 00000000..35844d46
--- /dev/null
+++ b/tests/testlanguage.c
@@ -0,0 +1,67 @@
+/* Pango
+ * testlanguage.c: Test program for PangoLanguage
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <pango/pango.h>
+
+static void
+test_language_to_string (void)
+{
+ PangoLanguage *lang;
+
+ lang = pango_language_from_string ("ja-jp");
+ g_assert_cmpstr (pango_language_to_string (lang), ==, "ja-jp");
+ g_assert_cmpstr ((pango_language_to_string) (lang), ==, "ja-jp");
+}
+
+static void
+test_language_env (void)
+{
+ if (g_test_subprocess ())
+ {
+ PangoLanguage **preferred;
+
+ g_setenv ("PANGO_LANGUAGE", "de:ja", TRUE);
+ g_setenv ("LANGUAGE", "fr", TRUE);
+
+ preferred = pango_language_get_preferred ();
+ g_assert_nonnull (preferred);
+ g_assert_true (preferred[0] == pango_language_from_string ("de"));
+ g_assert_true (preferred[1] == pango_language_from_string ("ja"));
+ g_assert_null (preferred[2]);
+
+ return;
+ }
+
+ g_test_trap_subprocess (NULL, 0, 0);
+ g_test_trap_assert_passed ();
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/language/to-string", test_language_to_string);
+ g_test_add_func ("/language/language-env", test_language_env);
+
+ return g_test_run ();
+}
diff --git a/tests/testmatrix.c b/tests/testmatrix.c
new file mode 100644
index 00000000..403dece1
--- /dev/null
+++ b/tests/testmatrix.c
@@ -0,0 +1,205 @@
+/* Pango
+ * testmatrix.c: Test program for PangoMatrix
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <math.h>
+#include <pango/pango.h>
+
+#define matrix_equal(m1, m2) \
+ (G_APPROX_VALUE ((m1)->xx, (m2)->xx, 0.0001) && \
+ G_APPROX_VALUE ((m1)->xy, (m2)->xy, 0.0001) && \
+ G_APPROX_VALUE ((m1)->yx, (m2)->yx, 0.0001) && \
+ G_APPROX_VALUE ((m1)->yy, (m2)->yy, 0.0001) && \
+ G_APPROX_VALUE ((m1)->x0, (m2)->x0, 0.0001) && \
+ G_APPROX_VALUE ((m1)->y0, (m2)->y0, 0.0001))
+
+static void
+test_matrix_translate (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoMatrix m2 = PANGO_MATRIX_INIT;
+
+ pango_matrix_translate (&m, 10, 10);
+ pango_matrix_translate (&m, -10, -10);
+
+ g_assert_true (matrix_equal (&m, &m2));
+}
+
+static void
+test_matrix_rotate (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoMatrix m2 = PANGO_MATRIX_INIT;
+
+ pango_matrix_rotate (&m, 90);
+ pango_matrix_rotate (&m, 90);
+ pango_matrix_rotate (&m, 90);
+ pango_matrix_rotate (&m, 90);
+
+ g_assert_true (matrix_equal (&m, &m2));
+}
+
+static void
+test_matrix_scale(void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoMatrix m2 = PANGO_MATRIX_INIT;
+
+ pango_matrix_scale (&m, 4, 5);
+ m2.xx = 4;
+ m2.yy = 5;
+
+ g_assert_true (matrix_equal (&m, &m2));
+}
+
+static void
+test_matrix_concat (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoMatrix id = PANGO_MATRIX_INIT;
+ PangoMatrix *m2;
+
+ pango_matrix_rotate (&m, 120);
+ m2 = pango_matrix_copy (&m);
+ pango_matrix_concat (m2, &m);
+ pango_matrix_concat (m2, &m);
+
+ g_assert_true (matrix_equal (&id, m2));
+
+ pango_matrix_free (m2);
+}
+
+static void
+test_matrix_font_scale (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ double x, y;
+
+ pango_matrix_scale (&m, 2, 3);
+
+ pango_matrix_get_font_scale_factors (&m, &x, &y);
+ g_assert_cmpfloat (x, ==, 2);
+ g_assert_cmpfloat (y, ==, 3);
+ g_assert_cmpfloat (pango_matrix_get_font_scale_factor (&m), ==, 3);
+
+ pango_matrix_rotate (&m, 90);
+ pango_matrix_get_font_scale_factors (&m, &x, &y);
+ g_assert_cmpfloat (x, ==, 3);
+ g_assert_cmpfloat (y, ==, 2);
+}
+
+static void
+test_matrix_transform_point (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ double x, y;
+
+ pango_matrix_translate (&m, 1, 1);
+ pango_matrix_scale (&m, 2, 4);
+ pango_matrix_rotate (&m, -90);
+
+ x = 1;
+ y = 0;
+
+ pango_matrix_transform_point (&m, &x, &y);
+
+ g_assert_cmpfloat_with_epsilon (x, 1, 0.001);
+ g_assert_cmpfloat_with_epsilon (y, 5, 0.001);
+}
+
+static void
+test_matrix_transform_distance (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ double x, y;
+
+ pango_matrix_translate (&m, 1, 1);
+ pango_matrix_scale (&m, 2, 4);
+ pango_matrix_rotate (&m, -90);
+
+ x = 1;
+ y = 0;
+
+ pango_matrix_transform_distance (&m, &x, &y);
+
+ g_assert_cmpfloat_with_epsilon (x, 0, 0.001);
+ g_assert_cmpfloat_with_epsilon (y, 4, 0.001);
+}
+
+static void
+test_matrix_transform_rect (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoRectangle rect;
+
+ pango_matrix_rotate (&m, 45);
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = 1 * PANGO_SCALE;
+ rect.height = 1 * PANGO_SCALE;
+
+ pango_matrix_transform_rectangle (&m, &rect);
+
+ g_assert_cmpfloat_with_epsilon (rect.x, 0, 0.5);
+ g_assert_cmpfloat_with_epsilon (rect.y, - M_SQRT2 / 2 * PANGO_SCALE, 0.5);
+ g_assert_cmpfloat_with_epsilon (rect.width, M_SQRT2 * PANGO_SCALE, 0.5);
+ g_assert_cmpfloat_with_epsilon (rect.height, M_SQRT2 * PANGO_SCALE, 0.5);
+}
+
+static void
+test_matrix_transform_pixel_rect (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+ PangoRectangle rect;
+
+ pango_matrix_rotate (&m, 45);
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = 1;
+ rect.height = 1;
+
+ pango_matrix_transform_pixel_rectangle (&m, &rect);
+
+ g_assert_cmpfloat_with_epsilon (rect.x, 0, 0.1);
+ g_assert_cmpfloat_with_epsilon (rect.y, -1, 0.1);
+ g_assert_cmpfloat_with_epsilon (rect.width, 2, 0.1);
+ g_assert_cmpfloat_with_epsilon (rect.height, 2, 0.1);
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/matrix/translate", test_matrix_translate);
+ g_test_add_func ("/matrix/rotate", test_matrix_rotate);
+ g_test_add_func ("/matrix/scale", test_matrix_scale);
+ g_test_add_func ("/matrix/concat", test_matrix_concat);
+ g_test_add_func ("/matrix/font-scale", test_matrix_font_scale);
+ g_test_add_func ("/matrix/transform-point", test_matrix_transform_point);
+ g_test_add_func ("/matrix/transform-distance", test_matrix_transform_distance);
+ g_test_add_func ("/matrix/transform-rect", test_matrix_transform_rect);
+ g_test_add_func ("/matrix/transform-pixel-rect", test_matrix_transform_pixel_rect);
+
+ return g_test_run ();
+}
diff --git a/tests/testmisc.c b/tests/testmisc.c
index b4467a63..a095cbf1 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -156,6 +156,148 @@ test_attr_list_update (void)
pango_attr_list_unref (list);
}
+static void
+test_version_info (void)
+{
+ char *str;
+
+ g_assert_null (pango_version_check (1, 0, 0));
+ g_assert_null (pango_version_check (PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR, PANGO_VERSION_MICRO));
+ g_assert_nonnull (pango_version_check (2, 0, 0));
+
+ str = g_strdup_printf ("%d.%d.%d", PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR, PANGO_VERSION_MICRO);
+ g_assert_cmpstr (str, ==, pango_version_string ());
+ g_free (str);
+}
+
+static void
+test_is_zero_width (void)
+{
+ g_assert_true (pango_is_zero_width (0x00ad));
+ g_assert_true (pango_is_zero_width (0x034f));
+ g_assert_false (pango_is_zero_width ('a'));
+ g_assert_false (pango_is_zero_width ('c'));
+}
+
+static void
+test_gravity_to_rotation (void)
+{
+ g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_SOUTH) == 0);
+ g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_NORTH) == G_PI);
+ g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_EAST) == -G_PI_2);
+ g_assert_true (pango_gravity_to_rotation (PANGO_GRAVITY_WEST) == G_PI_2);
+}
+
+static void
+test_gravity_from_matrix (void)
+{
+ PangoMatrix m = PANGO_MATRIX_INIT;
+
+ g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_SOUTH);
+
+ pango_matrix_rotate (&m, 90);
+ g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_WEST);
+
+ pango_matrix_rotate (&m, 90);
+ g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_NORTH);
+
+ pango_matrix_rotate (&m, 90);
+ g_assert_true (pango_gravity_get_for_matrix (&m) == PANGO_GRAVITY_EAST);
+}
+
+static void
+test_gravity_for_script (void)
+{
+ struct {
+ PangoScript script;
+ PangoGravity gravity;
+ PangoGravity gravity_natural;
+ PangoGravity gravity_line;
+ } tests[] = {
+ { PANGO_SCRIPT_ARABIC, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_NORTH },
+ { PANGO_SCRIPT_BOPOMOFO, PANGO_GRAVITY_EAST, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
+ { PANGO_SCRIPT_LATIN, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
+ { PANGO_SCRIPT_HANGUL, PANGO_GRAVITY_EAST, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
+ { PANGO_SCRIPT_MONGOLIAN, PANGO_GRAVITY_WEST, PANGO_GRAVITY_SOUTH },
+ { PANGO_SCRIPT_OGHAM, PANGO_GRAVITY_WEST, PANGO_GRAVITY_NORTH, PANGO_GRAVITY_SOUTH },
+ { PANGO_SCRIPT_TIBETAN, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_SOUTH },
+ };
+
+ for (int i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+ g_assert_true (pango_gravity_get_for_script (tests[i].script, PANGO_GRAVITY_AUTO, PANGO_GRAVITY_HINT_STRONG) == tests[i].gravity);
+
+ g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST, PANGO_GRAVITY_HINT_NATURAL) == tests[i].gravity_natural);
+ g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST, PANGO_GRAVITY_HINT_STRONG) == PANGO_GRAVITY_EAST);
+ g_assert_true (pango_gravity_get_for_script_and_width (tests[i].script, FALSE, PANGO_GRAVITY_EAST, PANGO_GRAVITY_HINT_LINE) == tests[i].gravity_line);
+ }
+}
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+static void
+test_bidi_type_for_unichar (void)
+{
+ /* one representative from each class we support */
+ g_assert_true (pango_bidi_type_for_unichar ('a') == PANGO_BIDI_TYPE_L);
+ g_assert_true (pango_bidi_type_for_unichar (0x202a) == PANGO_BIDI_TYPE_LRE);
+ g_assert_true (pango_bidi_type_for_unichar (0x202d) == PANGO_BIDI_TYPE_LRO);
+ g_assert_true (pango_bidi_type_for_unichar (0x05d0) == PANGO_BIDI_TYPE_R);
+ g_assert_true (pango_bidi_type_for_unichar (0x0627) == PANGO_BIDI_TYPE_AL);
+ g_assert_true (pango_bidi_type_for_unichar (0x202b) == PANGO_BIDI_TYPE_RLE);
+ g_assert_true (pango_bidi_type_for_unichar (0x202e) == PANGO_BIDI_TYPE_RLO);
+ g_assert_true (pango_bidi_type_for_unichar (0x202c) == PANGO_BIDI_TYPE_PDF);
+ g_assert_true (pango_bidi_type_for_unichar ('0') == PANGO_BIDI_TYPE_EN);
+ g_assert_true (pango_bidi_type_for_unichar ('+') == PANGO_BIDI_TYPE_ES);
+ g_assert_true (pango_bidi_type_for_unichar ('#') == PANGO_BIDI_TYPE_ET);
+ g_assert_true (pango_bidi_type_for_unichar (0x601) == PANGO_BIDI_TYPE_AN);
+ g_assert_true (pango_bidi_type_for_unichar (',') == PANGO_BIDI_TYPE_CS);
+ g_assert_true (pango_bidi_type_for_unichar (0x0301) == PANGO_BIDI_TYPE_NSM);
+ g_assert_true (pango_bidi_type_for_unichar (0x200d) == PANGO_BIDI_TYPE_BN);
+ g_assert_true (pango_bidi_type_for_unichar (0x2029) == PANGO_BIDI_TYPE_B);
+ g_assert_true (pango_bidi_type_for_unichar (0x000b) == PANGO_BIDI_TYPE_S);
+ g_assert_true (pango_bidi_type_for_unichar (' ') == PANGO_BIDI_TYPE_WS);
+ g_assert_true (pango_bidi_type_for_unichar ('!') == PANGO_BIDI_TYPE_ON);
+ /* these are new */
+ g_assert_true (pango_bidi_type_for_unichar (0x2066) == PANGO_BIDI_TYPE_LRI);
+ g_assert_true (pango_bidi_type_for_unichar (0x2067) == PANGO_BIDI_TYPE_RLI);
+ g_assert_true (pango_bidi_type_for_unichar (0x2068) == PANGO_BIDI_TYPE_FSI);
+ g_assert_true (pango_bidi_type_for_unichar (0x2069) == PANGO_BIDI_TYPE_PDI);
+}
+
+static void
+test_bidi_mirror_char (void)
+{
+ /* just some samples */
+ struct {
+ gunichar a;
+ gunichar b;
+ } tests[] = {
+ { '(', ')' },
+ { '<', '>' },
+ { '[', ']' },
+ { '{', '}' },
+ { 0x00ab, 0x00bb },
+ { 0x2045, 0x2046 },
+ { 0x226e, 0x226f },
+ };
+
+ for (int i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+ gboolean ret;
+ gunichar ch;
+
+ ret = pango_get_mirror_char (tests[i].a, &ch);
+ g_assert_true (ret);
+ g_assert_true (ch == tests[i].b);
+ ret = pango_get_mirror_char (tests[i].b, &ch);
+ g_assert_true (ret);
+ g_assert_true (ch == tests[i].a);
+ }
+}
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
int
main (int argc, char *argv[])
{
@@ -168,6 +310,13 @@ main (int argc, char *argv[])
g_test_add_func ("/language/emoji-crash", test_language_emoji_crash);
g_test_add_func ("/layout/line-height", test_line_height);
g_test_add_func ("/attr-list/update", test_attr_list_update);
+ g_test_add_func ("/version-info", test_version_info);
+ g_test_add_func ("/is-zerowidth", test_is_zero_width);
+ g_test_add_func ("/gravity/to-rotation", test_gravity_to_rotation);
+ g_test_add_func ("/gravity/from-matrix", test_gravity_from_matrix);
+ g_test_add_func ("/gravity/for-script", test_gravity_for_script);
+ g_test_add_func ("/bidi/type-for-unichar", test_bidi_type_for_unichar);
+ g_test_add_func ("/bidi/mirror-char", test_bidi_mirror_char);
return g_test_run ();
}
diff --git a/tests/testtabs.c b/tests/testtabs.c
new file mode 100644
index 00000000..2a62f1d6
--- /dev/null
+++ b/tests/testtabs.c
@@ -0,0 +1,110 @@
+/* Pango
+ * testtabs.c: Test program for PangoTabArray
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <pango/pango.h>
+
+static void
+test_tabs_basic (void)
+{
+ PangoTabArray *tabs;
+ PangoTabAlign align;
+ int location;
+
+ tabs = pango_tab_array_new (1, TRUE);
+
+ g_assert_true (pango_tab_array_get_positions_in_pixels (tabs));
+ g_assert_true (pango_tab_array_get_size (tabs) == 1);
+
+ pango_tab_array_set_tab (tabs, 0, PANGO_TAB_LEFT, 10);
+ pango_tab_array_get_tab (tabs, 0, &align, &location);
+ g_assert_true (align == PANGO_TAB_LEFT);
+ g_assert_true (location == 10);
+
+ pango_tab_array_free (tabs);
+}
+
+static void
+test_tabs_copy (void)
+{
+ PangoTabArray *tabs, *tabs2;
+ PangoTabAlign *alignments;
+ int *locations;
+
+ tabs = pango_tab_array_new_with_positions (2, TRUE,
+ PANGO_TAB_LEFT, 10,
+ PANGO_TAB_LEFT, 20);
+
+ tabs2 = pango_tab_array_copy (tabs);
+ pango_tab_array_get_tabs (tabs2, &alignments, &locations);
+ g_assert_true (alignments[0] == PANGO_TAB_LEFT);
+ g_assert_true (alignments[1] == PANGO_TAB_LEFT);
+ g_assert_true (locations[0] == 10);
+ g_assert_true (locations[1] == 20);
+
+ g_free (alignments);
+ g_free (locations);
+
+ pango_tab_array_free (tabs);
+ pango_tab_array_free (tabs2);
+}
+
+static void
+test_tabs_resize (void)
+{
+ PangoTabArray *tabs;
+ PangoTabAlign *alignments;
+ int *locations;
+
+ tabs = pango_tab_array_new (1, TRUE);
+
+ pango_tab_array_set_tab (tabs, 0, PANGO_TAB_LEFT, 10);
+
+ g_assert_true (pango_tab_array_get_size (tabs) == 1);
+
+ pango_tab_array_resize (tabs, 2);
+ g_assert_true (pango_tab_array_get_size (tabs) == 2);
+
+ pango_tab_array_set_tab (tabs, 1, PANGO_TAB_LEFT, 20);
+
+ pango_tab_array_get_tabs (tabs, &alignments, &locations);
+ g_assert_true (alignments[0] == PANGO_TAB_LEFT);
+ g_assert_true (alignments[1] == PANGO_TAB_LEFT);
+ g_assert_true (locations[0] == 10);
+ g_assert_true (locations[1] == 20);
+
+ g_free (alignments);
+ g_free (locations);
+
+ pango_tab_array_free (tabs);
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/tabs/basic", test_tabs_basic);
+ g_test_add_func ("/tabs/copy", test_tabs_copy);
+ g_test_add_func ("/tabs/resize", test_tabs_resize);
+
+ return g_test_run ();
+}