[vala/staging: 1/5] tests: Extend "GLib.Value (un-)boxing" test to increase coverage



commit 66457c710a5d7ab4611549e694c948ccfc09de2d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Mar 10 16:38:07 2020 +0100

    tests: Extend "GLib.Value (un-)boxing" test to increase coverage

 tests/structs/gvalue.vala | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/tests/structs/gvalue.vala b/tests/structs/gvalue.vala
index 927db0304..d6579a02c 100644
--- a/tests/structs/gvalue.vala
+++ b/tests/structs/gvalue.vala
@@ -48,6 +48,30 @@ void test_nullable_value_array () {
        }
 }
 
+class Bar {
+       public int i;
+}
+
+class Foo : Object {
+       public int i;
+}
+
+void test_gtype () {
+       var o = new Bar ();
+       o.i = 42;
+       Value vo = o;
+       Bar o2 = (Bar) vo;
+       assert (o2.i == 42);
+}
+
+void test_gobject () {
+       var o = new Foo ();
+       o.i = 42;
+       Value vo = o;
+       Foo o2 = (Foo) vo;
+       assert (o2.i == 42);
+}
+
 void take_value (Value v) {
 }
 
@@ -78,6 +102,8 @@ void main () {
        test_value_array ();
        test_nullable_value ();
        test_nullable_value_array ();
+       test_gtype ();
+       test_gobject ();
        take_value (make_bool ());
        test_try_cast_value ();
 }


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