| 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; |
| 3 | const expectEqual = std.testing.expectEqual; |
| 4 | |
| 5 | const Color = enum { |
| 6 | auto, |
| 7 | off, |
| 8 | on, |
| 9 | }; |
| 10 | |
| 11 | test "enum literals" { |
| 12 | const color1: Color = .auto; |
| 13 | const color2 = Color.auto; |
| 14 | try expectEqual(color1, color2); |
| 15 | } |
| 16 | |
| 17 | test "switch using enum literals" { |
| 18 | const color = Color.on; |
| 19 | const result = switch (color) { |
| 20 | .auto => false, |
| 21 | .on => true, |
| 22 | .off => false, |
| 23 | }; |
| 24 | try expect(result); |
| 25 | } |
| 26 | |
| 27 | // test |