tests length of zero allocation#25561
Conversation
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.
|
Built zig locally and ran The documentation for |
| // 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)))); |
There was a problem hiding this comment.
The check for length is needed in this test, however not sure this check of the ptr is needed. Created this check based on experiments and looking at how the current code works.
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.