[vala/0.36] tests: Extend "DBus errors" tests to increase coverage



commit 10245da98202ab7554aaa5b322c0950823c36c3b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jan 5 22:01:06 2019 +0100

    tests: Extend "DBus errors" tests to increase coverage

 tests/dbus/errors.test | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --git a/tests/dbus/errors.test b/tests/dbus/errors.test
index 9088fb4fd..ded8f959b 100644
--- a/tests/dbus/errors.test
+++ b/tests/dbus/errors.test
@@ -3,12 +3,20 @@ D-Bus
 
 Program: client
 
+[DBus (name = "org.example.TestError")]
+errordomain TestError {
+       NOT_SO_GOOD,
+       BAD,
+       WORSE
+}
+
 [DBus (name = "org.example.Test")]
 interface Test : Object {
        public abstract void test_void () throws Error;
        public abstract int test_int (int i, out int j) throws Error;
        public abstract string test_string (string s, out string t) throws Error;
        public abstract void test_cancellable (Cancellable? cancellable = null) throws Error;
+       public abstract void test_custom_error () throws TestError;
 }
 
 void main () {
@@ -44,10 +52,27 @@ void main () {
                assert_not_reached ();
        } catch {
        }
+
+       try {
+               test.test_custom_error ();
+               assert_not_reached ();
+       } catch (TestError e) {
+               assert (e is TestError.BAD);
+               assert (e.message == "GDBus.Error:org.example.TestError.Bad: Something failed badly");
+       } catch {
+               assert_not_reached ();
+       }
 }
 
 Program: server
 
+[DBus (name = "org.example.TestError")]
+errordomain TestError {
+       NOT_SO_GOOD,
+       BAD,
+       WORSE
+}
+
 [DBus (name = "org.example.Test")]
 class Test : Object {
        public void test_void () throws Error {
@@ -64,6 +89,10 @@ class Test : Object {
 
        public void test_cancellable (Cancellable? cancellable = null) throws Error {
        }
+
+       public void test_custom_error () throws TestError {
+               throw new TestError.BAD ("Something failed badly");
+       }
 }
 
 MainLoop main_loop;


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