1 // Copyright 2010 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.
13 // testGetenv gives us a controlled set of variables for testing Expand.
14 func testGetenv(s
string) string {
36 var expandTests
= []struct {
40 {"$*", "all the args"},
42 {"${*}", "all the args"},
44 {"${1}", "ARGUMENT1"},
45 {"now is the time", "now is the time"},
46 {"$HOME", "/usr/gopher"},
47 {"$home_1", "/usr/foo"},
48 {"${HOME}", "/usr/gopher"},
49 {"${H}OME", "(Value of H)OME"},
50 {"A$$$#$1$H$home_1*B", "APIDNARGSARGUMENT1(Value of H)/usr/foo*B"},
53 func TestExpand(t
*testing
.T
) {
54 for _
, test
:= range expandTests
{
55 result
:= Expand(test
.in
, testGetenv
)
56 if result
!= test
.out
{
57 t
.Errorf("Expand(%q)=%q; expected %q", test
.in
, result
, test
.out
)
62 func TestConsistentEnviron(t
*testing
.T
) {
64 for i
:= 0; i
< 10; i
++ {
66 if !reflect
.DeepEqual(e0
, e1
) {
67 t
.Fatalf("environment changed")