about summary refs log tree commit diff
path: root/lang/zig/switch-enum-literal.zig
blob: 550de93a015faab5c265a97c636c90a9d5aee7f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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);
}