mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
libstd: add smoke test for insert methods in MultiArrayList
This commit is contained in:
parent
144e36770e
commit
90343d1868
1 changed files with 19 additions and 0 deletions
|
|
@ -602,3 +602,22 @@ test "ensure capacity on empty list" {
|
|||
try testing.expectEqualSlices(u32, &[_]u32{ 9, 11 }, list.items(.a));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 10, 12 }, list.items(.b));
|
||||
}
|
||||
|
||||
test "insert elements" {
|
||||
const ally = testing.allocator;
|
||||
|
||||
const Foo = struct {
|
||||
a: u8,
|
||||
b: u32,
|
||||
};
|
||||
|
||||
var list = MultiArrayList(Foo){};
|
||||
defer list.deinit(ally);
|
||||
|
||||
try list.insert(ally, 0, .{ .a = 1, .b = 2 });
|
||||
try list.ensureUnusedCapacity(ally, 1);
|
||||
list.insertAssumeCapacity(1, .{ .a = 2, .b = 3 });
|
||||
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 1, 2 }, list.items(.a));
|
||||
try testing.expectEqualSlices(u32, &[_]u32{ 2, 3 }, list.items(.b));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue