diff options
| author | Russ Cox <rsc@golang.org> | 2009-10-06 19:41:51 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-10-06 19:41:51 -0700 |
| commit | 6c2652e6fd54ce34ca3be95540c54cebb52bfece (patch) | |
| tree | 2366cc62ab4dee2e5698d6d6e5b299d6819a7edd /src/pkg/http/request_test.go | |
| parent | db62e99a735a036afda2098f1a721fe8dbf6ce76 (diff) | |
| download | golang-6c2652e6fd54ce34ca3be95540c54cebb52bfece.tar.gz | |
apply gofmt to go, gob, hash, http, image, io, json, log
R=gri
DELTA=1359 (138 added, 32 deleted, 1189 changed)
OCL=35408
CL=35420
Diffstat (limited to 'src/pkg/http/request_test.go')
| -rw-r--r-- | src/pkg/http/request_test.go | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/pkg/http/request_test.go b/src/pkg/http/request_test.go index d45e0ed6b..94da01521 100644 --- a/src/pkg/http/request_test.go +++ b/src/pkg/http/request_test.go @@ -9,25 +9,25 @@ import ( "testing"; ) -type stringMultimap map[string] []string +type stringMultimap map[string][]string type parseTest struct { - query string; - out stringMultimap; + query string; + out stringMultimap; } var parseTests = []parseTest{ parseTest{ query: "a=1&b=2", - out: stringMultimap{ "a": []string{ "1" }, "b": []string{ "2" } }, + out: stringMultimap{"a": []string{"1"}, "b": []string{"2"}}, }, parseTest{ query: "a=1&a=2&a=banana", - out: stringMultimap{ "a": []string{ "1", "2", "banana" } }, + out: stringMultimap{"a": []string{"1", "2", "banana"}}, }, parseTest{ query: "ascii=%3Ckey%3A+0x90%3E", - out: stringMultimap{ "ascii": []string{ "<key: 0x90>" } }, + out: stringMultimap{"ascii": []string{"<key: 0x90>"}}, }, } @@ -36,7 +36,7 @@ func TestParseForm(t *testing.T) { form, err := parseForm(test.query); if err != nil { t.Errorf("test %d: Unexpected error: %v", i, err); - continue + continue; } if len(form) != len(test.out) { t.Errorf("test %d: len(form) = %d, want %d", i, len(form), len(test.out)); @@ -45,11 +45,11 @@ func TestParseForm(t *testing.T) { vs, ok := form[k]; if !ok { t.Errorf("test %d: Missing key %q", i, k); - continue + continue; } if len(vs) != len(evs) { t.Errorf("test %d: len(form[%q]) = %d, want %d", i, k, len(vs), len(evs)); - continue + continue; } for j, ev := range evs { if v := vs[j]; v != ev { @@ -61,7 +61,7 @@ func TestParseForm(t *testing.T) { } func TestQuery(t *testing.T) { - req := &Request{ Method: "GET" }; + req := &Request{Method: "GET"}; req.Url, _ = ParseURL("http://www.google.com/search?q=foo&q=bar"); if q := req.FormValue("q"); q != "foo" { t.Errorf(`req.FormValue("q") = %q, want "foo"`, q); @@ -70,22 +70,16 @@ func TestQuery(t *testing.T) { type stringMap map[string]string type parseContentTypeTest struct { - contentType stringMap; - error bool; + contentType stringMap; + error bool; } var parseContentTypeTests = []parseContentTypeTest{ + parseContentTypeTest{contentType: stringMap{"Content-Type": "text/plain"}}, + parseContentTypeTest{contentType: stringMap{"Content-Type": ""}}, + parseContentTypeTest{contentType: stringMap{"Content-Type": "text/plain; boundary="}}, parseContentTypeTest{ - contentType: stringMap{ "Content-Type": "text/plain" }, - }, - parseContentTypeTest{ - contentType: stringMap{ "Content-Type": "" }, - }, - parseContentTypeTest{ - contentType: stringMap{ "Content-Type": "text/plain; boundary=" }, - }, - parseContentTypeTest{ - contentType: stringMap{ "Content-Type": "application/unknown" }, + contentType: stringMap{"Content-Type": "application/unknown"}, error: true, }, } @@ -93,9 +87,9 @@ var parseContentTypeTests = []parseContentTypeTest{ func TestPostContentTypeParsing(t *testing.T) { for i, test := range parseContentTypeTests { req := &Request{ - Method: "POST", - Header: test.contentType, - Body: bytes.NewBufferString("body") + Method: "POST", + Header: test.contentType, + Body: bytes.NewBufferString("body"), }; err := req.ParseForm(); if !test.error && err != nil { |
