test_exhaustive_switch.zig (326B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 4 const Color = enum { 5 auto, 6 off, 7 on, 8 }; 9 10 test "enum literals with switch" { 11 const color = Color.off; 12 const result = switch (color) { 13 .auto => false, 14 .on => false, 15 .off => true, 16 }; 17 try expect(result); 18 } 19 20 // test