mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
21 lines
326 B
Zig
21 lines
326 B
Zig
|
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
|