From 2056b8f9d17fb7a0e53215327e1ba4f65a375680 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 4 Jan 2011 16:33:27 +0000 Subject: [PATCH] Add a regression test for errors containing underscores Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30274 --- test/core/my-object.c | 15 +++++++++++++++ test/core/my-object.h | 3 ++- test/core/test-dbus-glib.c | 11 +++++++++++ test/core/test-service-glib.xml | 3 +++ 4 files changed, 31 insertions(+), 1 deletions(-) diff --git a/test/core/my-object.c b/test/core/my-object.c index acb8afa..ec0e301 100644 --- a/test/core/my-object.c +++ b/test/core/my-object.c @@ -5,6 +5,9 @@ #include "my-object.h" #include "my-object-marshal.h" +static gboolean my_object_throw_error_under_score (MyObject *obj, + GError **error); + #include "test-service-glib-glue.h" /* Properties */ @@ -222,6 +225,7 @@ my_object_error_get_type (void) ENUM_ENTRY (MY_OBJECT_ERROR_FOO, "Foo"), ENUM_ENTRY (MY_OBJECT_ERROR_BAR, "Bar"), ENUM_ENTRY (MY_OBJECT_ERROR_MULTI_WORD, "Multi-word"), + ENUM_ENTRY (MY_OBJECT_ERROR_UNDER_SCORE, "Under_score"), { 0, 0, 0 } }; @@ -298,6 +302,17 @@ my_object_throw_error_multi_word (MyObject *obj, GError **error) return FALSE; } +static gboolean +my_object_throw_error_under_score (MyObject *obj, GError **error) +{ + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_UNDER_SCORE, + "%s", + "this method's error has an underscore"); + return FALSE; +} + gboolean my_object_throw_unregistered_error (MyObject *obj, GError **error) { diff --git a/test/core/my-object.h b/test/core/my-object.h index a93d7fd..657140d 100644 --- a/test/core/my-object.h +++ b/test/core/my-object.h @@ -35,7 +35,8 @@ typedef enum { MY_OBJECT_ERROR_FOO, MY_OBJECT_ERROR_BAR, - MY_OBJECT_ERROR_MULTI_WORD + MY_OBJECT_ERROR_MULTI_WORD, + MY_OBJECT_ERROR_UNDER_SCORE } MyObjectError; #define MY_OBJECT_ERROR (my_object_error_quark ()) diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 1eb36fb..f86cba9 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -899,6 +899,17 @@ main (int argc, char **argv) g_print ("(wrapped) ThrowErrorMultiWord failed (as expected) returned error: %s\n", error->message); g_clear_error (&error); + g_print ("Calling (wrapped) throw_error_under_score\n"); + if (org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_under_score (proxy, &error) != FALSE) + lose ("(wrapped) ThrowErrorUnderScore call unexpectedly succeeded!"); + + g_assert_error (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_assert_cmpstr (dbus_g_error_get_name (error), ==, + "org.freedesktop.DBus.GLib.Tests.MyObject.Under_score"); + + g_print ("(wrapped) ThrowErrorUnderScore failed (as expected) returned error: %s\n", error->message); + g_clear_error (&error); + if (org_freedesktop_DBus_GLib_Tests_MyObject_async_throw_error (proxy, &error) != FALSE) lose ("(wrapped) AsyncThrowError call unexpectedly succeeded!"); diff --git a/test/core/test-service-glib.xml b/test/core/test-service-glib.xml index 84a3c29..94a836a 100644 --- a/test/core/test-service-glib.xml +++ b/test/core/test-service-glib.xml @@ -37,6 +37,9 @@ + + + -- 1.7.2.3