about summary refs log tree commit diff
path: root/lang/zig/switch-enum-literal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lang/zig/switch-enum-literal.zig')
-rw-r--r--lang/zig/switch-enum-literal.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/lang/zig/switch-enum-literal.zig b/lang/zig/switch-enum-literal.zig
new file mode 100644
index 0000000..550de93
--- /dev/null
+++ b/lang/zig/switch-enum-literal.zig
@@ -0,0 +1,13 @@
+const std = @import("std");
+const expect = std.testing.expect;
+
+const Color = enum { auto, off, on };
+
+test "enum literals with switch" {
+    const color = Color.off;
+    const result = switch (color) {
+        .auto, .on => false,
+        .off => true,
+    };
+    expect(result);
+}