diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-01-30 10:01:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 10:01:40 -0500 |
| commit | 65b1a4953fd5b87f30260beb363d0e968dc8e291 (patch) | |
| tree | ab01d1b6699d103b4b075807f47c136926404f92 /lib/std/testing.zig | |
| parent | e3a383a661aaf9b43016358e2951ff9d792f240e (diff) | |
| parent | 9c196efa2afe0e337ac0b16bd1138e89393f6106 (diff) | |
| download | zig-65b1a4953fd5b87f30260beb363d0e968dc8e291.tar.gz zig-65b1a4953fd5b87f30260beb363d0e968dc8e291.zip | |
Merge pull request #4324 from fengb/testing-allocator
Remove debug.global_allocator in favor of testing.allocator
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 7a261e0751..f8247b5a9d 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -2,6 +2,18 @@ const builtin = @import("builtin"); const TypeId = builtin.TypeId; const std = @import("std.zig"); +pub const LeakCountAllocator = @import("testing/leak_count_allocator.zig").LeakCountAllocator; +pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAllocator; + +/// This should only be used in temporary test programs. +pub const allocator = &allocator_instance.allocator; +pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator); + +pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator; + +pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); +var allocator_mem: [512 * 1024]u8 = undefined; + /// This function is intended to be used only in tests. It prints diagnostics to stderr /// and then aborts when actual_error_union is not expected_error. pub fn expectError(expected_error: anyerror, actual_error_union: var) void { |
