test ergonomics

thanks tsmanner
This commit is contained in:
Motiejus Jakštys 2022-03-18 17:55:28 +01:00 committed by Motiejus Jakštys
parent e4e845384f
commit 0331364da2

View File

@ -774,16 +774,14 @@ test "bdzIdx on str" {
} }
test "nblocks" { test "nblocks" {
const T = struct { want: u32, arr: []const u8 }; const tests = .{
const tests = &[_]T{ .{ 0, &[_]u8{} },
.{ .want = 0, .arr = &[_]u8{} }, .{ 1, &[_]u8{ 1, 2, 42 } },
.{ .want = 1, .arr = &[_]u8{ 1, 2, 42 } }, .{ 1, &[_]u8{1} ** 63 },
.{ .want = 1, .arr = &[_]u8{1} ** 63 }, .{ 1, &[_]u8{1} ** 64 },
.{ .want = 1, .arr = &[_]u8{1} ** 64 }, .{ 2, &[_]u8{1} ** 65 },
.{ .want = 2, .arr = &[_]u8{1} ** 65 },
}; };
for (tests) |tt| { inline for (tests) |tt|
try testing.expectEqual(tt.want, nblocks(tt.arr)); try testing.expectEqual(@as(u32, tt[0]), nblocks(tt[1]));
}
} }