From a740e9744d589dadf9f5a23c4ddf531fcda46e3c Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Wed, 28 Apr 2021 21:33:10 +0200 Subject: [PATCH] tests: Add "properties in structs" test to increase coverage --- tests/Makefile.am | 1 + tests/structs/properties.vala | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/structs/properties.vala 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"); + } +} -- 2.47.2