mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
27 lines
450 B
Zig
27 lines
450 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const Color = enum {
|
|
auto,
|
|
off,
|
|
on,
|
|
};
|
|
|
|
test "enum literals" {
|
|
const color1: Color = .auto;
|
|
const color2 = Color.auto;
|
|
try expect(color1 == color2);
|
|
}
|
|
|
|
test "switch using enum literals" {
|
|
const color = Color.on;
|
|
const result = switch (color) {
|
|
.auto => false,
|
|
.on => true,
|
|
.off => false,
|
|
};
|
|
try expect(result);
|
|
}
|
|
|
|
// test
|