[vala/staging] tests: Add "properties in structs" test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add "properties in structs" test to increase coverage
- Date: Wed, 28 Apr 2021 19:33:44 +0000 (UTC)
commit 6ecf8bc56371f90e0d53e02f214c8e53ce40a446
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Apr 28 21:33:10 2021 +0200
tests: Add "properties in structs" test to increase coverage
tests/Makefile.am | 1 +
tests/structs/properties.vala | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b5a1acf04..64e7101cf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -346,6 +346,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");
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]