testing_detect_leak.zig (277B) - Raw
1 const std = @import("std"); 2 3 test "detect leak" { 4 var list = std.array_list.Managed(u21).init(std.testing.allocator); 5 // missing `defer list.deinit();` 6 try list.append('☔'); 7 8 try std.testing.expect(list.items.len == 1); 9 } 10 11 // test_error=1 tests leaked memory