zig/doc/langref/testing_detect_leak.zig

12 lines
268 B
Zig
Raw Normal View History

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