mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 04:44:47 +01:00
16 lines
349 B
Zig
16 lines
349 B
Zig
const std = @import("std");
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
const Payload = union {
|
|
int: i64,
|
|
float: f64,
|
|
boolean: bool,
|
|
};
|
|
test "simple union" {
|
|
var payload = Payload{ .int = 1234 };
|
|
try expectEqual(1234, payload.int);
|
|
payload = Payload{ .float = 12.34 };
|
|
try expectEqual(12.34, payload.float);
|
|
}
|
|
|
|
// test
|