[pango/test-coverage: 5/20] tests: Improve markup test coverage




commit 5f9019b8fbe77010d694a171d99a61e4f277bd37
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 26 14:51:56 2021 -0400

    tests: Improve markup test coverage
    
    Cover many more error cases.

 tests/markup-parse.c            | 122 +++++++++++++++++++++++++++++++++++++++-
 tests/markups/fail-10.expected  |   1 +
 tests/markups/fail-10.markup    |  11 ++++
 tests/markups/fail-11.expected  |   1 +
 tests/markups/fail-11.markup    |   1 +
 tests/markups/fail-12.expected  |   1 +
 tests/markups/fail-12.markup    |   1 +
 tests/markups/fail-13.expected  |   1 +
 tests/markups/fail-13.markup    |   1 +
 tests/markups/fail-14.expected  |   1 +
 tests/markups/fail-14.markup    |   1 +
 tests/markups/fail-15.expected  |   1 +
 tests/markups/fail-15.markup    |   1 +
 tests/markups/fail-16.expected  |   1 +
 tests/markups/fail-16.markup    |   1 +
 tests/markups/fail-17.expected  |   1 +
 tests/markups/fail-17.markup    |   1 +
 tests/markups/fail-18.markup    |   1 +
 tests/markups/fail-19.expected  |   1 +
 tests/markups/fail-19.markup    |   1 +
 tests/markups/fail-20.expected  |   1 +
 tests/markups/fail-20.markup    |   1 +
 tests/markups/fail-21.expected  |   1 +
 tests/markups/fail-21.markup    |   1 +
 tests/markups/fail-22.expected  |   1 +
 tests/markups/fail-22.markup    |   1 +
 tests/markups/fail-23.expected  |   1 +
 tests/markups/fail-23.markup    |   1 +
 tests/markups/fail-24.expected  |   1 +
 tests/markups/fail-24.markup    |   1 +
 tests/markups/fail-25.expected  |   1 +
 tests/markups/fail-25.markup    |   1 +
 tests/markups/fail-26.expected  |   1 +
 tests/markups/fail-26.markup    |   1 +
 tests/markups/fail-27.expected  |   1 +
 tests/markups/fail-27.markup    |   1 +
 tests/markups/fail-28.expected  |   1 +
 tests/markups/fail-28.markup    |   1 +
 tests/markups/fail-29.expected  |   1 +
 tests/markups/fail-29.markup    |   1 +
 tests/markups/fail-30.expected  |   1 +
 tests/markups/fail-30.markup    |   1 +
 tests/markups/fail-31.expected  |   1 +
 tests/markups/fail-31.markup    |   1 +
 tests/markups/fail-32.expected  |   1 +
 tests/markups/fail-32.markup    |   1 +
 tests/markups/fail-33.expected  |   1 +
 tests/markups/fail-33.markup    |   1 +
 tests/markups/fail-34.expected  |   1 +
 tests/markups/fail-34.markup    |   1 +
 tests/markups/fail-35.expected  |   1 +
 tests/markups/fail-35.markup    |   1 +
 tests/markups/fail-36.expected  |   1 +
 tests/markups/fail-36.markup    |   1 +
 tests/markups/fail-37.expected  |   1 +
 tests/markups/fail-37.markup    |   1 +
 tests/markups/fail-38.expected  |   1 +
 tests/markups/fail-38.markup    |   1 +
 tests/markups/fail-39.expected  |   1 +
 tests/markups/fail-39.markup    |   1 +
 tests/markups/fail-6.expected   |   1 +
 tests/markups/fail-6.markup     |   1 +
 tests/markups/fail-7.expected   |   1 +
 tests/markups/fail-7.markup     |   1 +
 tests/markups/fail-8.expected   |   1 +
 tests/markups/fail-8.markup     |   1 +
 tests/markups/fail-9.expected   |   1 +
 tests/markups/fail-9.markup     |  11 ++++
 tests/markups/valid-10.markup   |   4 +-
 tests/markups/valid-11.markup   |   4 +-
 tests/markups/valid-16.expected |  27 +++++++++
 tests/markups/valid-16.markup   |   1 +
 tests/markups/valid-17.expected |  14 +++++
 tests/markups/valid-17.markup   |   1 +
 tests/markups/valid-18.expected |  24 ++++++++
 tests/markups/valid-18.markup   |  11 ++++
 tests/markups/valid-19.expected |  18 ++++++
 tests/markups/valid-19.markup   |   5 ++
 tests/markups/valid-2.expected  |   2 +-
 tests/markups/valid-2.markup    |   2 +-
 tests/markups/valid-3.expected  |   1 +
 tests/markups/valid-3.markup    |   1 +
 tests/markups/valid-8.expected  |  67 +++++++++++++++++++---
 tests/markups/valid-8.markup    |  13 +++--
 tests/test-common.c             |  19 +++++++
 tests/test-common.h             |   4 ++
 86 files changed, 407 insertions(+), 20 deletions(-)
---
diff --git a/tests/markup-parse.c b/tests/markup-parse.c
index 9f081ab7..5a79f5a5 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,116 @@ 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 ('_');
+
+  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);
+    }
+}
+
+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 +288,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-18.markup b/tests/markups/fail-18.markup
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/tests/markups/fail-18.markup
@@ -0,0 +1 @@
+
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/test-common.c b/tests/test-common.c
index 18ee4a40..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)
 {
diff --git a/tests/test-common.h b/tests/test-common.h
index a357c2a9..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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]