]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extend "GLib.Value (un-)boxing" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 10 Mar 2020 15:38:07 +0000 (16:38 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 10 Mar 2020 17:10:01 +0000 (18:10 +0100)
tests/structs/gvalue.vala

index 927db030431a4cf72b808d985e563e9227dd70c1..5283fc8185ff4f1f35e69548d6ab1d15c06a498c 100644 (file)
@@ -48,6 +48,41 @@ void test_nullable_value_array () {
        }
 }
 
+class Bar {
+       public int i;
+}
+
+interface Manam : Object {
+}
+
+class Foo : Object, Manam {
+       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 test_ginterface () {
+       Manam i = new Foo ();
+       ((Foo) i).i = 42;
+       Value vi = i;
+       Manam i2 = (Manam) vi;
+       assert (((Foo) i2).i == 42);
+}
+
 void take_value (Value v) {
 }
 
@@ -78,6 +113,9 @@ void main () {
        test_value_array ();
        test_nullable_value ();
        test_nullable_value_array ();
+       test_gtype ();
+       test_gobject ();
+       test_ginterface ();
        take_value (make_bool ());
        test_try_cast_value ();
 }