fn init(internal_allocator: mem.Allocator, fail_index: usize) FailingAllocator

fail_index is the number of successful allocations you can expect from this allocator. The next allocation will fail. For example, if this is called with fail_index equal to 2, the following test will pass:

var a = try failing_alloc.create(i32); var b = try failing_alloc.create(i32); testing.expectError(error.OutOfMemory, failing_alloc.create(i32));

Parameters

internal_allocator: mem.Allocator,
fail_index: usize,