mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
28 lines
498 B
Zig
28 lines
498 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
const Color = enum {
|
|
auto,
|
|
off,
|
|
on,
|
|
};
|
|
|
|
test "enum literals" {
|
|
const color1: Color = .auto;
|
|
const color2 = Color.auto;
|
|
try expectEqual(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
|