diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-14 10:27:44 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-14 10:27:44 -0500 |
| commit | a8b36fbe34e4acfea1fcb348fbed321b05611fd3 (patch) | |
| tree | 23f489f85c427a003577f5c40b74201ba8c85ddb /lib/std/io.zig | |
| parent | cdc5070f216a924d24588b8d0fe06400e036e6bf (diff) | |
| parent | 40b9db7cad6f876bb3e8fa32d7b32bbd4bc983ea (diff) | |
| download | zig-a8b36fbe34e4acfea1fcb348fbed321b05611fd3.tar.gz zig-a8b36fbe34e4acfea1fcb348fbed321b05611fd3.zip | |
Merge remote-tracking branch 'origin/master' into llvm10
Diffstat (limited to 'lib/std/io.zig')
| -rw-r--r-- | lib/std/io.zig | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/std/io.zig b/lib/std/io.zig index 341b73e33c..16bfffdcad 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -223,15 +223,13 @@ test "io.BufferedInStream" { } }; - var buf: [100]u8 = undefined; - const allocator = &std.heap.FixedBufferAllocator.init(buf[0..]).allocator; - const str = "This is a test"; var one_byte_stream = OneByteReadInStream.init(str); var buf_in_stream = BufferedInStream(OneByteReadInStream.Error).init(&one_byte_stream.stream); const stream = &buf_in_stream.stream; - const res = try stream.readAllAlloc(allocator, str.len + 1); + const res = try stream.readAllAlloc(testing.allocator, str.len + 1); + defer testing.allocator.free(res); testing.expectEqualSlices(u8, str, res); } @@ -874,10 +872,8 @@ pub fn readLineFrom(stream: var, buf: *std.Buffer) ![]u8 { } test "io.readLineFrom" { - var bytes: [128]u8 = undefined; - const allocator = &std.heap.FixedBufferAllocator.init(bytes[0..]).allocator; - - var buf = try std.Buffer.initSize(allocator, 0); + var buf = try std.Buffer.initSize(testing.allocator, 0); + defer buf.deinit(); var mem_stream = SliceInStream.init( \\Line 1 \\Line 22 |
