authorgravatar for suirad@users.noreply.github.comSuirad <suirad@users.noreply.github.com> 2018-11-24 17:29:06-06:00
committergravatar for suirad@users.noreply.github.comSuirad <suirad@users.noreply.github.com> 2018-11-30 02:08:34-06:00
log0abd5520bdc8118369895f67f581d10c847ac139
treeab9c925b622fa96295e8d5607597b35e596be295
parent5dfca87a65884f8564a8c8e2444bb906073425f3

Platform specific tests


1 files changed, 20 insertions(+), 7 deletions(-)

std/os/index.zig+20-7
......@@ -775,15 +775,26 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
775775
776776test "os.getEnvMap" {
777777 var env = try getEnvMap(std.debug.global_allocator);
778 var seen_path = false;
778 var seen_home = false;
779779 var it = env.iterator();
780780 while (it.next()) |pair| {
781 if (mem.eql(u8, pair.key, "PATH")) {
782 seen_path = true;
783 }
781 switch (builtin.os){
782 builtin.Os.windows => {
783 if (mem.eql(u8, pair.key, "HOMEPATH")) {
784 seen_home = true;
785 }
786 },
787 builtin.Os.linux, builtin.Os.macosx,
788 builtin.Os.ios => {
789 if (mem.eql(u8, pair.key, "HOME")) {
790 seen_home = true;
791 }
792 },
793 else => @compileError("unimplemented"),
794 }
784795 }
785796
786 assert(seen_path == true);
797 assert(seen_home == true);
787798}
788799
789800/// TODO make this go through libc when we have it
......@@ -854,8 +865,10 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned
854865
855866test "os.getEnvVarOwned" {
856867 switch (builtin.os) {
857 builtin.Os.windows, builtin.Os.linux, builtin.Os.macosx,
858 builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "PATH"),
868 builtin.Os.windows => _ = try getEnvVarOwned(debug.global_allocator, "HOMEPATH"),
869
870 builtin.Os.linux, builtin.Os.macosx,
871 builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "HOME"),
859872 else => @compileError("unimplemented"),
860873 }
861874}