[gtk+/parser: 33/57] tests: (Try to) print the actual enum value in the errors file



commit b6ab29d1d40fa63d0ce8fc87c15b2d2f22834e72
Author: Benjamin Otte <otte redhat com>
Date:   Fri Apr 8 16:59:17 2011 +0200

    tests: (Try to) print the actual enum value in the errors file
    
    Instead of gtk-some-error-quark 5, print
    GTK_SOME_ERROR_SOMETHING_FAILED.

 tests/css/parser/close-at-end-of-file.errors |    2 +-
 tests/css/parser/does-not-exist.errors       |    2 +-
 tests/css/parser/test-css-parser.c           |   34 +++++++++++++++++++++----
 3 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/tests/css/parser/close-at-end-of-file.errors b/tests/css/parser/close-at-end-of-file.errors
index 341b007..69b3390 100644
--- a/tests/css/parser/close-at-end-of-file.errors
+++ b/tests/css/parser/close-at-end-of-file.errors
@@ -1 +1 @@
-close-at-end-of-file.css:3: error: gtk-css-provider-error-quark 1
+close-at-end-of-file.css:3: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
diff --git a/tests/css/parser/does-not-exist.errors b/tests/css/parser/does-not-exist.errors
index eb57998..22d7743 100644
--- a/tests/css/parser/does-not-exist.errors
+++ b/tests/css/parser/does-not-exist.errors
@@ -1 +1 @@
-does-not-exist.css:2: error: gtk-css-provider-error-quark 2
+does-not-exist.css:2: error: GTK_CSS_PROVIDER_ERROR_PROPERTY_NAME
diff --git a/tests/css/parser/test-css-parser.c b/tests/css/parser/test-css-parser.c
index 326e812..07620de 100644
--- a/tests/css/parser/test-css-parser.c
+++ b/tests/css/parser/test-css-parser.c
@@ -117,6 +117,22 @@ done:
 }
 
 static void
+append_error_value (GString *string,
+                    GType    enum_type,
+                    guint    value)
+{
+  GEnumClass *enum_class;
+  GEnumValue *enum_value;
+
+  enum_class = g_type_class_ref (enum_type);
+  enum_value = g_enum_get_value (enum_class, value);
+
+  g_string_append (string, enum_value->value_name);
+
+  g_type_class_unref (enum_class);
+}
+
+static void
 parsing_error_cb (GtkCssProvider *provider,
                   const gchar     *path,
                   guint            line,
@@ -130,14 +146,20 @@ parsing_error_cb (GtkCssProvider *provider,
   g_assert (line > 0);
 
   basename = g_path_get_basename (path);
-
   g_string_append_printf (errors,
-                          "%s:%u: error: %s %u\n",
-                          basename, line,
-                          g_quark_to_string (error->domain),
-                          error->code);
-
+                          "%s:%u: error: ",
+                          basename, line);
   g_free (basename);
+                          
+  if (error->domain == GTK_CSS_PROVIDER_ERROR)
+      append_error_value (errors, GTK_TYPE_CSS_PROVIDER_ERROR, error->code);
+  else
+    g_string_append_printf (errors, 
+                            "%s %u\n",
+                            g_quark_to_string (error->domain),
+                            error->code);
+
+  g_string_append_c (errors, '\n');
 }
 
 static void



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