]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "struct (un)boxing" variant test
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 24 Mar 2019 17:34:29 +0000 (18:34 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 10 Apr 2019 14:26:19 +0000 (16:26 +0200)
tests/basic-types/gvariants.vala

index ebfedb9c758672cd10555ab319f48e7aa93438f6..41ca600b292c467a60c309a1a74437671e3409d8 100644 (file)
@@ -52,11 +52,27 @@ void double_array_2d_conversion () {
        assert (da[1,1] == 23.42);
 }
 
+struct Foo {
+       public string s;
+       public uint64 u64;
+       public bool b;
+}
+
+void struct_conversion () {
+       Foo s = { "foo", uint64.MAX, true };
+       Variant v = s;
+       Foo st = (Foo) v;
+       assert (st.s == "foo");
+       assert (st.u64 == uint64.MAX);
+       assert (st.b == true);
+}
+
 void main () {
        string_conversion ();
        string_array_conversion ();
        double_conversion ();
        double_array_conversion ();
+       struct_conversion ();
 
        string_array_2d_conversion ();
        double_array_2d_conversion ();