mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
tests length of zero allocation
Test code for zero length allocation was not checking the length of the returned slice was zero. Added a check for this. Also added a check for the pointer based on examining how the current code works.
This commit is contained in:
parent
87c18945c2
commit
8fb0cedce3
1 changed files with 2 additions and 0 deletions
|
|
@ -598,6 +598,8 @@ pub fn testAllocator(base_allocator: mem.Allocator) !void {
|
|||
|
||||
// Zero-length allocation
|
||||
const empty = try allocator.alloc(u8, 0);
|
||||
try testing.expect(empty.len == 0);
|
||||
try testing.expect(empty.ptr == @as([*]u8, @ptrFromInt(std.math.maxInt(usize))));
|
||||
allocator.free(empty);
|
||||
// Allocation with zero-sized types
|
||||
const zero_bit_ptr = try allocator.create(u0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue