From: Rico Tzschichholz Date: Tue, 10 Mar 2020 15:38:07 +0000 (+0100) Subject: tests: Extend "GLib.Value (un-)boxing" test to increase coverage X-Git-Tag: 0.48.1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf01f3ee80e5b1204805ff9f35db11fc4e885a52;p=thirdparty%2Fvala.git tests: Extend "GLib.Value (un-)boxing" test to increase coverage --- diff --git a/tests/structs/gvalue.vala b/tests/structs/gvalue.vala index 927db0304..5283fc818 100644 --- a/tests/structs/gvalue.vala +++ b/tests/structs/gvalue.vala @@ -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 (); }