From: Rico Tzschichholz Date: Wed, 28 Apr 2021 19:33:10 +0000 (+0200) Subject: tests: Add "properties in structs" test to increase coverage X-Git-Tag: 0.50.9~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a740e9744d589dadf9f5a23c4ddf531fcda46e3c;p=thirdparty%2Fvala.git tests: Add "properties in structs" test to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index b143f825e..2ecc783ac 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..60991af61 --- /dev/null +++ b/tests/structs/properties.vala @@ -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"); + } +}