Skip to content

Commit 2936602

Browse files
committed
add behavior test for union with 128 bit integer
closes #9871
1 parent 8796123 commit 2936602

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/behavior/union.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,3 +1692,24 @@ test "packed union field pointer has correct alignment" {
16921692
try expectEqual(@as(u20, 456), bp.*);
16931693
try expectEqual(@as(u20, 789), cp.*);
16941694
}
1695+
1696+
test "union with 128 bit integer" {
1697+
const ValueTag = enum { int, other };
1698+
1699+
const Value3 = union(ValueTag) {
1700+
int: i128,
1701+
other: bool,
1702+
};
1703+
var values: [2]Value3 = undefined;
1704+
values[0] = .{ .int = 3 };
1705+
values[1] = .{ .int = 4 };
1706+
1707+
var ok: usize = 0;
1708+
1709+
for (values) |val| {
1710+
switch (val) {
1711+
.int => ok += 1,
1712+
else => return error.TestFailed,
1713+
}
1714+
}
1715+
}

0 commit comments

Comments
 (0)