aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/testing_detect_leak.zig
blob: c99fc03bf6d05553e2cb8538c74fffbbd6f06c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
const std = @import("std");

test "detect leak" {
    var list = std.array_list.Managed(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