test_anonymous_struct.zig (433B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 4 test "fully anonymous struct" { 5 try check(.{ 6 .int = @as(u32, 1234), 7 .float = @as(f64, 12.34), 8 .b = true, 9 .s = "hi", 10 }); 11 } 12 13 fn check(args: anytype) !void { 14 try expect(args.int == 1234); 15 try expect(args.float == 12.34); 16 try expect(args.b); 17 try expect(args.s[0] == 'h'); 18 try expect(args.s[1] == 'i'); 19 } 20 21 // test