github.com/hlts2/go@v0.0.0-20170904000733-812b34efaed8/src/os/exec/env_test.go (about) 1 // Copyright 2017 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. 4 5 package exec 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestDedupEnv(t *testing.T) { 13 tests := []struct { 14 noCase bool 15 in []string 16 want []string 17 }{ 18 { 19 noCase: true, 20 in: []string{"k1=v1", "k2=v2", "K1=v3"}, 21 want: []string{"K1=v3", "k2=v2"}, 22 }, 23 { 24 noCase: false, 25 in: []string{"k1=v1", "K1=V2", "k1=v3"}, 26 want: []string{"k1=v3", "K1=V2"}, 27 }, 28 { 29 in: []string{"=a", "=b", "foo", "bar"}, 30 want: []string{"=b", "foo", "bar"}, 31 }, 32 } 33 for _, tt := range tests { 34 got := dedupEnvCase(tt.noCase, tt.in) 35 if !reflect.DeepEqual(got, tt.want) { 36 t.Errorf("Dedup(%v, %q) = %q; want %q", tt.noCase, tt.in, got, tt.want) 37 } 38 } 39 }