mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 00:52:52 +00:00
17 lines
333 B
Zig
17 lines
333 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const Payload = union {
|
|
int: i64,
|
|
float: f64,
|
|
boolean: bool,
|
|
};
|
|
test "simple union" {
|
|
var payload = Payload{ .int = 1234 };
|
|
try expect(payload.int == 1234);
|
|
payload = Payload{ .float = 12.34 };
|
|
try expect(payload.float == 12.34);
|
|
}
|
|
|
|
// test
|