1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
15 var setenvEinvalTests
= []struct {
18 {"", ""}, // empty key
19 {"k=v", ""}, // '=' in key
20 {"\x00", ""}, // '\x00' in key
21 {"k", "\x00"}, // '\x00' in value
24 func TestSetenvUnixEinval(t
*testing
.T
) {
25 for _
, tt
:= range setenvEinvalTests
{
26 err
:= Setenv(tt
.k
, tt
.v
)
28 t
.Errorf(`Setenv(%q, %q) == nil, want error`, tt
.k
, tt
.v
)
33 var shellSpecialVarTests
= []struct {
40 {"!", "exclamation mark"},
41 {"?", "question mark"},
45 func TestExpandEnvShellSpecialVar(t
*testing
.T
) {
46 for _
, tt
:= range shellSpecialVarTests
{
50 argRaw
:= fmt
.Sprintf("$%s", tt
.k
)
51 argWithBrace
:= fmt
.Sprintf("${%s}", tt
.k
)
52 if gotRaw
, gotBrace
:= ExpandEnv(argRaw
), ExpandEnv(argWithBrace
); gotRaw
!= gotBrace
{
53 t
.Errorf("ExpandEnv(%q) = %q, ExpandEnv(%q) = %q; expect them to be equal", argRaw
, gotRaw
, argWithBrace
, gotBrace
)