mirror of
https://github.com/ziglang/zig.git
synced 2025-12-21 21:53:08 +00:00
28 lines
473 B
Zig
28 lines
473 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const Number = enum(u8) {
|
|
one,
|
|
two,
|
|
three,
|
|
_,
|
|
};
|
|
|
|
test "switch on non-exhaustive enum" {
|
|
const number = Number.one;
|
|
const result = switch (number) {
|
|
.one => true,
|
|
.two,
|
|
.three => false,
|
|
_ => false,
|
|
};
|
|
try expect(result);
|
|
const is_one = switch (number) {
|
|
.one => true,
|
|
else => false,
|
|
};
|
|
try expect(is_one);
|
|
}
|
|
|
|
// test
|