[librsvg/librsvg-2.44] (#415): Test the all the values in the RsvgError enum
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.44] (#415): Test the all the values in the RsvgError enum
- Date: Fri, 15 Feb 2019 18:31:57 +0000 (UTC)
commit 8cffa65aca02c18fbd10ce58bc4b026e57d5b06e
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Feb 15 12:07:37 2019 -0600
(#415): Test the all the values in the RsvgError enum
Finishes fixing https://gitlab.gnome.org/GNOME/librsvg/issues/415
tests/api.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 46 insertions(+), 18 deletions(-)
---
diff --git a/tests/api.c b/tests/api.c
index 1f34ea6c..10376d7f 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -84,6 +84,51 @@ flags_registration (void)
g_type_class_unref (type_class);
}
+static gboolean
+enum_value_matches (GEnumValue *v,
+ gint value,
+ const char *value_name,
+ const char *value_nick)
+{
+ return (v->value == value
+ && strcmp (v->value_name, value_name) == 0
+ && strcmp (v->value_nick, value_nick) == 0);
+}
+
+static void
+error_registration (void)
+{
+ GType ty;
+ GTypeQuery q;
+ GTypeClass *type_class;
+ GEnumClass *enum_class;
+
+ g_assert_cmpint (RSVG_ERROR, !=, 0);
+
+ ty = RSVG_TYPE_ERROR;
+
+ g_assert (ty != G_TYPE_INVALID);
+
+ g_type_query (ty, &q);
+ g_assert (q.type == ty);
+ g_assert (G_TYPE_IS_ENUM (q.type));
+ g_assert_cmpstr (q.type_name, ==, "RsvgError");
+
+ type_class = g_type_class_ref (ty);
+ g_assert (G_IS_ENUM_CLASS (type_class));
+ g_assert (G_ENUM_CLASS_TYPE (type_class) == ty);
+
+ enum_class = G_ENUM_CLASS (type_class);
+ g_assert (enum_class->n_values == 1);
+
+ g_assert (enum_value_matches (&enum_class->values[0],
+ RSVG_ERROR_FAILED,
+ "RSVG_ERROR_FAILED",
+ "failed"));
+
+ g_type_class_unref (type_class);
+}
+
static char *
get_test_filename (const char *basename) {
return g_build_filename (test_utils_get_test_data_path (),
@@ -261,22 +306,6 @@ set_dpi (void)
g_assert_cmpint (dim_100_dpi.height * 3, ==, dim_200_300_dpi.height);
}
-static void
-error_quark (void)
-{
- g_assert_cmpint (rsvg_error_quark(), !=, 0);
-}
-
-static void
-auto_generated (void)
-{
- GTypeQuery q;
-
- g_type_query (RSVG_TYPE_ERROR, &q);
- g_assert (G_TYPE_IS_ENUM (q.type));
- g_assert_cmpstr (q.type_name, ==, "RsvgError");
-}
-
static void
handle_write_close_free (void)
{
@@ -672,10 +701,9 @@ main (int argc, char **argv)
g_test_add_func ("/api/handle_has_gtype", handle_has_gtype);
g_test_add_func ("/api/flags_registration", flags_registration);
+ g_test_add_func ("/api/error_registration", error_registration);
g_test_add_func ("/api/noops", noops);
g_test_add_func ("/api/set_dpi", set_dpi);
- g_test_add_func ("/api/error_quark", error_quark);
- g_test_add_func ("/api/auto_generated", auto_generated);
g_test_add_func ("/api/handle_write_close_free", handle_write_close_free);
g_test_add_func ("/api/handle_new_from_file", handle_new_from_file);
g_test_add_func ("/api/handle_new_from_data", handle_new_from_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]