mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
22 lines
453 B
Zig
22 lines
453 B
Zig
|
const std = @import("std");
|
||
|
const expect = std.testing.expect;
|
||
|
|
||
|
test "tuple" {
|
||
|
const values = .{
|
||
|
@as(u32, 1234),
|
||
|
@as(f64, 12.34),
|
||
|
true,
|
||
|
"hi",
|
||
|
} ++ .{false} ** 2;
|
||
|
try expect(values[0] == 1234);
|
||
|
try expect(values[4] == false);
|
||
|
inline for (values, 0..) |v, i| {
|
||
|
if (i != 2) continue;
|
||
|
try expect(v);
|
||
|
}
|
||
|
try expect(values.len == 6);
|
||
|
try expect(values.@"3"[0] == 'h');
|
||
|
}
|
||
|
|
||
|
// test
|