diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-10-14 15:12:40 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-10-15 14:42:11 +0000 |
| commit | d3ae2d2749d2e26dcfc84ed1ea6a0cfb513ab863 (patch) | |
| tree | a1e25cd234a2db64198088c7a6a79f6f5eda1740 /src/net/http/cgi/host_test.go | |
| parent | 167a7123997c42e91d69de2203fc4c156897f0a2 (diff) | |
| download | go-d3ae2d2749d2e26dcfc84ed1ea6a0cfb513ab863.tar.xz | |
net/http/cgi: optimize internal function removeLeadingDuplicates a bit
Change-Id: I0255f24f5c5925ea4daa28a28d23606df35d4373
Reviewed-on: https://go-review.googlesource.com/15824
Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/net/http/cgi/host_test.go')
| -rw-r--r-- | src/net/http/cgi/host_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/net/http/cgi/host_test.go b/src/net/http/cgi/host_test.go index 8a82789fd3..33277640ea 100644 --- a/src/net/http/cgi/host_test.go +++ b/src/net/http/cgi/host_test.go @@ -16,6 +16,7 @@ import ( "os" "os/exec" "path/filepath" + "reflect" "runtime" "strconv" "strings" @@ -498,3 +499,25 @@ func TestEnvOverride(t *testing.T) { } runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) } + +func TestRemoveLeadingDuplicates(t *testing.T) { + tests := []struct { + env []string + want []string + }{ + { + env: []string{"a=b", "b=c", "a=b2"}, + want: []string{"b=c", "a=b2"}, + }, + { + env: []string{"a=b", "b=c", "d", "e=f"}, + want: []string{"a=b", "b=c", "d", "e=f"}, + }, + } + for _, tt := range tests { + got := removeLeadingDuplicates(tt.env) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("removeLeadingDuplicates(%q) = %q; want %q", tt.env, got, tt.want) + } + } +} |
