diff options
Diffstat (limited to 'libgo/go/os/env_unix_test.go')
-rw-r--r-- | libgo/go/os/env_unix_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libgo/go/os/env_unix_test.go b/libgo/go/os/env_unix_test.go index 5ec07ee1b1..f7b67ebbb8 100644 --- a/libgo/go/os/env_unix_test.go +++ b/libgo/go/os/env_unix_test.go @@ -7,6 +7,7 @@ package os_test import ( + "fmt" . "os" "testing" ) @@ -28,3 +29,28 @@ func TestSetenvUnixEinval(t *testing.T) { } } } + +var shellSpecialVarTests = []struct { + k, v string +}{ + {"*", "asterisk"}, + {"#", "pound"}, + {"$", "dollar"}, + {"@", "at"}, + {"!", "exclamation mark"}, + {"?", "question mark"}, + {"-", "dash"}, +} + +func TestExpandEnvShellSpecialVar(t *testing.T) { + for _, tt := range shellSpecialVarTests { + Setenv(tt.k, tt.v) + defer Unsetenv(tt.k) + + argRaw := fmt.Sprintf("$%s", tt.k) + argWithBrace := fmt.Sprintf("${%s}", tt.k) + if gotRaw, gotBrace := ExpandEnv(argRaw), ExpandEnv(argWithBrace); gotRaw != gotBrace { + t.Errorf("ExpandEnv(%q) = %q, ExpandEnv(%q) = %q; expect them to be equal", argRaw, gotRaw, argWithBrace, gotBrace) + } + } +} |