[vala/staging] tests: Add "enum typed property" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add "enum typed property" tests to increase coverage
- Date: Fri, 7 Aug 2020 17:07:11 +0000 (UTC)
commit 884856bd3bc7cd1e22606dfa3d0e403e028122f9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Aug 6 22:29:35 2020 +0200
tests: Add "enum typed property" tests to increase coverage
tests/Makefile.am | 1 +
tests/objects/property-enum.vala | 62 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8c857cb81..b28a2a45f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -417,6 +417,7 @@ TESTS = \
objects/property-array.vala \
objects/property-array-length.vala \
objects/property-base-access.vala \
+ objects/property-enum.vala \
objects/property-notify.vala \
objects/property-ownership.vala \
objects/property-read-only-auto.vala \
diff --git a/tests/objects/property-enum.vala b/tests/objects/property-enum.vala
new file mode 100644
index 000000000..df7aeabe6
--- /dev/null
+++ b/tests/objects/property-enum.vala
@@ -0,0 +1,62 @@
+public enum FooEnum {
+ VALUE1,
+ VALUE2;
+}
+
+[Flags]
+public enum FooFlag {
+ VALUE1,
+ VALUE2;
+}
+
+[CCode (has_type_id = false)]
+public enum BarEnum {
+ VALUE1,
+ VALUE2;
+}
+
+[Flags]
+[CCode (has_type_id = false)]
+public enum BarFlag {
+ VALUE1,
+ VALUE2;
+}
+
+public class Manam {
+ public FooEnum prop1 { get; set; }
+ public FooFlag prop2 { get; set; }
+ public BarEnum prop3 { get; set; }
+ public BarFlag prop4 { get; set; }
+}
+
+public class Minim : Object {
+ public FooEnum prop1 { get; set; }
+ public FooFlag prop2 { get; set; }
+ public BarEnum prop3 { get; set; }
+ public BarFlag prop4 { get; set; }
+}
+
+void main () {
+ {
+ var manam = new Manam ();
+ manam.prop1 = FooEnum.VALUE2;
+ assert (manam.prop1 == FooEnum.VALUE2);
+ manam.prop2 = FooFlag.VALUE2;
+ assert (manam.prop2 == FooFlag.VALUE2);
+ manam.prop3 = BarEnum.VALUE2;
+ assert (manam.prop3 == BarEnum.VALUE2);
+ manam.prop4 = BarFlag.VALUE2;
+ assert (manam.prop4 == BarFlag.VALUE2);
+ }
+ {
+ var minim = new Minim ();
+ minim.prop1 = FooEnum.VALUE2;
+ assert (minim.prop1 == FooEnum.VALUE2);
+ minim.prop2 = FooFlag.VALUE2;
+ assert (minim.prop2 == FooFlag.VALUE2);
+ minim.prop3 = BarEnum.VALUE2;
+ assert (minim.prop3 == BarEnum.VALUE2);
+ minim.prop4 = BarFlag.VALUE2;
+ assert (minim.prop4 == BarFlag.VALUE2);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]