]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "properties in structs" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 28 Apr 2021 19:33:10 +0000 (21:33 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 19 May 2021 06:52:19 +0000 (08:52 +0200)
tests/Makefile.am
tests/structs/properties.vala [new file with mode: 0644]

index b143f825e16c064b846fc2a9e11ed5759baed9f8..2ecc783acc766d9f0bca1ee3135932c82fcf6ece 100644 (file)
@@ -344,6 +344,7 @@ TESTS = \
        structs/gtype-base-struct.vala \
        structs/gvalue.vala \
        structs/gvalue-implicit-comparison.vala \
+       structs/properties.vala \
        structs/simple-type-constructor.vala \
        structs/simple-type-disposable.test \
        structs/bug530605.vala \
diff --git a/tests/structs/properties.vala b/tests/structs/properties.vala
new file mode 100644 (file)
index 0000000..60991af
--- /dev/null
@@ -0,0 +1,35 @@
+struct Foo {
+       public int i { get; set; }
+       public string s { get; set; }
+       public string os { owned get; set; }
+
+       public string s_get {
+               get {
+                       return _s;
+               }
+       }
+
+       public string s_set {
+               set {
+                       _s = value;
+               }
+       }
+}
+
+void main () {
+       {
+               Foo foo = { 23, "foo", "bar" };
+               assert (foo.i == 23);
+               assert (foo.s == "foo");
+               assert (foo.s_get == "foo");
+               assert (foo.os == "bar");
+
+               foo.i = 42;
+               foo.s_set = "bar";
+               foo.os = "manam";
+               assert (foo.i == 42);
+               assert (foo.s == "bar");
+               assert (foo.s_get == "bar");
+               assert (foo.os == "manam");
+       }
+}