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/fs | |
| 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/fs')
| -rw-r--r-- | lib/std/fs/get_app_data_dir.zig | 6 | ||||
| -rw-r--r-- | lib/std/fs/path.zig | 10 |
2 files changed, 6 insertions, 10 deletions
diff --git a/lib/std/fs/get_app_data_dir.zig b/lib/std/fs/get_app_data_dir.zig index cb26e335de..35c0265435 100644 --- a/lib/std/fs/get_app_data_dir.zig +++ b/lib/std/fs/get_app_data_dir.zig @@ -56,9 +56,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD } test "getAppDataDir" { - var buf: [512]u8 = undefined; - const allocator = &std.heap.FixedBufferAllocator.init(buf[0..]).allocator; - // We can't actually validate the result - _ = getAppDataDir(allocator, "zig") catch return; + const dir = getAppDataDir(std.testing.allocator, "zig") catch return; + defer std.testing.allocator.free(dir); } diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index f6f34585be..5d1c775629 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -89,16 +89,14 @@ pub fn joinPosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { } fn testJoinWindows(paths: []const []const u8, expected: []const u8) void { - var buf: [1024]u8 = undefined; - const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; - const actual = joinWindows(a, paths) catch @panic("fail"); + const actual = joinWindows(testing.allocator, paths) catch @panic("fail"); + defer testing.allocator.free(actual); testing.expectEqualSlices(u8, expected, actual); } fn testJoinPosix(paths: []const []const u8, expected: []const u8) void { - var buf: [1024]u8 = undefined; - const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; - const actual = joinPosix(a, paths) catch @panic("fail"); + const actual = joinPosix(testing.allocator, paths) catch @panic("fail"); + defer testing.allocator.free(actual); testing.expectEqualSlices(u8, expected, actual); } |
