const expect = @import("std").testing.expect; const Color = enum { auto, off, on }; test "enum literals" { const color1: Color = .auto; const color2 = Color.auto; expect(color1 == color2); expect(color1 == .auto); } test "switch using enum literals" { expect(switch (Color.on) { .auto => false, .on => true, .off => false, }); } const Number = enum(u8) { one, two, three, _ }; test "switch on non-exhaustive enum" { const number = Number.one; expect(switch (number) { .one => true, .two, .three => false, _ => false, }); const is_one = switch (number) { .one => true, else => false, }; expect(is_one); }