From 2936602566c5c460abae350a6d59c1da0e0989ee Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 26 Jul 2023 17:25:54 -0700 Subject: [PATCH] add behavior test for union with 128 bit integer closes #9871 --- test/behavior/union.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/behavior/union.zig b/test/behavior/union.zig index f7a481e311..3ea6f17a26 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -1692,3 +1692,24 @@ test "packed union field pointer has correct alignment" { try expectEqual(@as(u20, 456), bp.*); try expectEqual(@as(u20, 789), cp.*); } + +test "union with 128 bit integer" { + const ValueTag = enum { int, other }; + + const Value3 = union(ValueTag) { + int: i128, + other: bool, + }; + var values: [2]Value3 = undefined; + values[0] = .{ .int = 3 }; + values[1] = .{ .int = 4 }; + + var ok: usize = 0; + + for (values) |val| { + switch (val) { + .int => ok += 1, + else => return error.TestFailed, + } + } +}