[vala/0.36] tests: Add "struct (un)boxing" variant test
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] tests: Add "struct (un)boxing" variant test
- Date: Wed, 10 Apr 2019 13:25:18 +0000 (UTC)
commit a5d36078a9eb407dc7bb20213c797002728e6124
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Mar 24 18:34:29 2019 +0100
tests: Add "struct (un)boxing" variant test
tests/basic-types/gvariants.vala | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/tests/basic-types/gvariants.vala b/tests/basic-types/gvariants.vala
index ebfedb9c7..41ca600b2 100644
--- a/tests/basic-types/gvariants.vala
+++ b/tests/basic-types/gvariants.vala
@@ -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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]