summaryrefslogtreecommitdiff
path: root/tests/enums
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2014-03-26 20:13:06 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2014-03-26 20:22:15 +0100
commitd9dff687875a2ae033719799d8a77487917bd159 (patch)
treea18c5510059333254022ba0efc179133df1e5406 /tests/enums
parent55ea3d742092fe4110ad854105d2aebce9ac0ac0 (diff)
downloadvala-d9dff687875a2ae033719799d8a77487917bd159.tar.gz
Add tests for enums annotated with [Flags]
Diffstat (limited to 'tests/enums')
-rw-r--r--tests/enums/flags.vala31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/enums/flags.vala b/tests/enums/flags.vala
new file mode 100644
index 000000000..52b439d24
--- /dev/null
+++ b/tests/enums/flags.vala
@@ -0,0 +1,31 @@
+using GLib;
+
+[Flags]
+enum Foo {
+ VAL1,
+ VAL2,
+ VAL3
+}
+
+void main () {
+ Foo foo, bar, baz;
+
+ foo = (Foo.VAL1 | Foo.VAL2 | Foo.VAL3);
+ bar = (Foo.VAL1 | Foo.VAL2);
+ baz = (bar | Foo.VAL3);
+
+ assert (Foo.VAL1 == 1 << 0);
+ assert (Foo.VAL2 == 1 << 1);
+ assert (Foo.VAL3 == 1 << 2);
+
+ assert (Foo.VAL1 in bar);
+ assert ((Foo.VAL1 | Foo.VAL2) in bar);
+ assert (!(Foo.VAL3 in bar));
+
+ assert (Foo.VAL1 in baz);
+ assert (Foo.VAL2 in baz);
+ assert (Foo.VAL3 in baz);
+
+ assert (bar in foo);
+}
+