aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_exhaustive_switch.zig
blob: 00b10ee91249e842026c12618088b59c993c65a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 => false,
        .on => false,
        .off => true,
    };
    try expect(result);
}

// test