mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Platform specific tests
This commit is contained in:
parent
5dfca87a65
commit
0abd5520bd
@ -775,15 +775,26 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
|
||||
|
||||
test "os.getEnvMap" {
|
||||
var env = try getEnvMap(std.debug.global_allocator);
|
||||
var seen_path = false;
|
||||
var seen_home = false;
|
||||
var it = env.iterator();
|
||||
while (it.next()) |pair| {
|
||||
if (mem.eql(u8, pair.key, "PATH")) {
|
||||
seen_path = true;
|
||||
}
|
||||
switch (builtin.os){
|
||||
builtin.Os.windows => {
|
||||
if (mem.eql(u8, pair.key, "HOMEPATH")) {
|
||||
seen_home = true;
|
||||
}
|
||||
},
|
||||
builtin.Os.linux, builtin.Os.macosx,
|
||||
builtin.Os.ios => {
|
||||
if (mem.eql(u8, pair.key, "HOME")) {
|
||||
seen_home = true;
|
||||
}
|
||||
},
|
||||
else => @compileError("unimplemented"),
|
||||
}
|
||||
}
|
||||
|
||||
assert(seen_path == true);
|
||||
assert(seen_home == true);
|
||||
}
|
||||
|
||||
/// TODO make this go through libc when we have it
|
||||
@ -854,8 +865,10 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned
|
||||
|
||||
test "os.getEnvVarOwned" {
|
||||
switch (builtin.os) {
|
||||
builtin.Os.windows, builtin.Os.linux, builtin.Os.macosx,
|
||||
builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "PATH"),
|
||||
builtin.Os.windows => _ = try getEnvVarOwned(debug.global_allocator, "HOMEPATH"),
|
||||
|
||||
builtin.Os.linux, builtin.Os.macosx,
|
||||
builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "HOME"),
|
||||
else => @compileError("unimplemented"),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user