Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(62)

Side by Side Diff: src/pkg/http/request_test.go

Issue 223076: code review 223076: gofmt: experiment: align values in map composites where... (Closed)
Patch Set: code review 223076: gofmt: experiment: align values in map composites where... Created 15 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/http/request.go ('k') | src/pkg/http/requestwrite_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package http 5 package http
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 ) 10 )
11 11
12 type stringMultimap map[string][]string 12 type stringMultimap map[string][]string
13 13
14 type parseTest struct { 14 type parseTest struct {
15 query string 15 query string
16 out stringMultimap 16 out stringMultimap
17 } 17 }
18 18
19 var parseTests = []parseTest{ 19 var parseTests = []parseTest{
20 parseTest{ 20 parseTest{
21 query: "a=1&b=2", 21 query: "a=1&b=2",
22 » » out: stringMultimap{"a": []string{"1"}, "b": []string{"2"}}, 22 » » out: stringMultimap{"a": []string{"1"}, "b": []string{"2"}},
23 }, 23 },
24 parseTest{ 24 parseTest{
25 query: "a=1&a=2&a=banana", 25 query: "a=1&a=2&a=banana",
26 » » out: stringMultimap{"a": []string{"1", "2", "banana"}}, 26 » » out: stringMultimap{"a": []string{"1", "2", "banana"}},
27 }, 27 },
28 parseTest{ 28 parseTest{
29 query: "ascii=%3Ckey%3A+0x90%3E", 29 query: "ascii=%3Ckey%3A+0x90%3E",
30 » » out: stringMultimap{"ascii": []string{"<key: 0x90>"}}, 30 » » out: stringMultimap{"ascii": []string{"<key: 0x90>"}},
31 }, 31 },
32 } 32 }
33 33
34 func TestParseForm(t *testing.T) { 34 func TestParseForm(t *testing.T) {
35 for i, test := range parseTests { 35 for i, test := range parseTests {
36 form := make(map[string][]string) 36 form := make(map[string][]string)
37 err := parseForm(form, test.query) 37 err := parseForm(form, test.query)
38 if err != nil { 38 if err != nil {
39 t.Errorf("test %d: Unexpected error: %v", i, err) 39 t.Errorf("test %d: Unexpected error: %v", i, err)
40 continue 40 continue
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 contentType: stringMap{"Content-Type": "application/unknown"}, 83 contentType: stringMap{"Content-Type": "application/unknown"},
84 error: true, 84 error: true,
85 }, 85 },
86 } 86 }
87 87
88 func TestPostContentTypeParsing(t *testing.T) { 88 func TestPostContentTypeParsing(t *testing.T) {
89 for i, test := range parseContentTypeTests { 89 for i, test := range parseContentTypeTests {
90 req := &Request{ 90 req := &Request{
91 Method: "POST", 91 Method: "POST",
92 Header: test.contentType, 92 Header: test.contentType,
93 » » » Body: nopCloser{bytes.NewBufferString("body")}, 93 » » » Body: nopCloser{bytes.NewBufferString("body")},
94 } 94 }
95 err := req.ParseForm() 95 err := req.ParseForm()
96 if !test.error && err != nil { 96 if !test.error && err != nil {
97 t.Errorf("test %d: Unexpected error: %v", i, err) 97 t.Errorf("test %d: Unexpected error: %v", i, err)
98 } 98 }
99 if test.error && err == nil { 99 if test.error && err == nil {
100 t.Errorf("test %d should have returned error", i) 100 t.Errorf("test %d should have returned error", i)
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 func TestRedirect(t *testing.T) { 105 func TestRedirect(t *testing.T) {
106 const ( 106 const (
107 start = "http://codesearch.google.com/" 107 start = "http://codesearch.google.com/"
108 end = "http://www.google.com/codesearch" 108 end = "http://www.google.com/codesearch"
109 ) 109 )
110 r, url, err := Get(start) 110 r, url, err := Get(start)
111 if err != nil { 111 if err != nil {
112 t.Fatal(err) 112 t.Fatal(err)
113 } 113 }
114 r.Body.Close() 114 r.Body.Close()
115 if r.StatusCode != 200 || url != end { 115 if r.StatusCode != 200 || url != end {
116 t.Fatalf("Get(%s) got status %d at %s, want 200 at %s", start, r .StatusCode, url, end) 116 t.Fatalf("Get(%s) got status %d at %s, want 200 at %s", start, r .StatusCode, url, end)
117 } 117 }
118 } 118 }
OLDNEW
« no previous file with comments | « src/pkg/http/request.go ('k') | src/pkg/http/requestwrite_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b