Created
November 26, 2018 02:32
-
-
Save ibebrett/16894bb263637f15a5ff9fd575c5b042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const zalloc = @import("zalloc/index.zig"); | |
const std = @import("std"); | |
const debug = std.debug; | |
const Allocator = std.mem.Allocator; | |
test "test idiotic alloc low value" { | |
var allocator: Allocator = zalloc.IdioticAllocator(200).init().allocator; | |
var slice = try allocator.alloc(*i32, 100); | |
debug.assert(slice.len == 100); | |
} | |
test "test alloc too big" { | |
var allocator: Allocator = zalloc.IdioticAllocator(200).init().allocator; | |
if (allocator.alloc(*i32, 10000)) |slice| { | |
@panic("Should not be able to reserve an array of 10000"); | |
} else |err| { | |
debug.assert(err == Allocator.Error.OutOfMemory); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment