zig/doc/langref/testing_detect_leak.zig
meowjesty 6bcf0066b1
Use .empty for initialization.
Co-authored-by: Rue <78876133+IOKG04@users.noreply.github.com>
2025-11-22 22:18:27 -03:00

12 lines
313 B
Zig

const std = @import("std");
test "detect leak" {
const allocator = std.testing.allocator;
var list: std.ArrayList(u21) = .empty;
// missing `defer list.deinit(allocator);`
try list.append(allocator, '☔');
try std.testing.expect(list.items.len == 1);
}
// test_error=1 tests leaked memory