mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
Add unit test for std.fs.wasi.PreopenList
This commit is contained in:
parent
c7721bb368
commit
200f9ea6fb
@ -146,3 +146,17 @@ pub const PreopenList = struct {
|
||||
return self.buffer.toOwnedSlice();
|
||||
}
|
||||
};
|
||||
|
||||
test "extracting WASI preopens" {
|
||||
if (@import("builtin").os.tag != .wasi) return error.SkipZigTest;
|
||||
|
||||
var preopens = PreopenList.init(std.testing.allocator);
|
||||
defer preopens.deinit();
|
||||
|
||||
try preopens.populate();
|
||||
|
||||
std.testing.expectEqual(@as(usize, 1), preopens.asSlice().len);
|
||||
const preopen = preopens.find(".") orelse unreachable;
|
||||
std.testing.expect(std.mem.eql(u8, ".", preopen.@"type".Dir));
|
||||
std.testing.expectEqual(@as(usize, 3), preopen.fd);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user