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

Delta Between Two Patch Sets: src/pkg/http/cgi/host_test.go

Issue 4661051: code review 4661051: strings.Split: make the default to split all. (Closed)
Left Patch Set: Created 12 years, 9 months ago
Right Patch Set: diff -r eaa696629d4d https://go.googlecode.com/hg/ Created 12 years, 9 months 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/http/cgi/host.go ('k') | src/pkg/http/cookie.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 // Tests for package cgi 5 // Tests for package cgi
6 6
7 package cgi 7 package cgi
8 8
9 import ( 9 import (
10 "bufio" 10 "bufio"
(...skipping 28 matching lines...) Expand all
39 for { 39 for {
40 line, err := rw.Body.ReadString('\n') 40 line, err := rw.Body.ReadString('\n')
41 switch { 41 switch {
42 case err == os.EOF: 42 case err == os.EOF:
43 break readlines 43 break readlines
44 case err != nil: 44 case err != nil:
45 t.Fatalf("unexpected error reading from CGI: %v", err) 45 t.Fatalf("unexpected error reading from CGI: %v", err)
46 } 46 }
47 linesRead++ 47 linesRead++
48 trimmedLine := strings.TrimRight(line, "\r\n") 48 trimmedLine := strings.TrimRight(line, "\r\n")
49 » » split := strings.Split(trimmedLine, "=", 2) 49 » » split := strings.SplitN(trimmedLine, "=", 2)
50 if len(split) != 2 { 50 if len(split) != 2 {
51 t.Fatalf("Unexpected %d parts from invalid line number % v: %q; existing map=%v", 51 t.Fatalf("Unexpected %d parts from invalid line number % v: %q; existing map=%v",
52 len(split), linesRead, line, m) 52 len(split), linesRead, line, m)
53 } 53 }
54 m[split[0]] = split[1] 54 m[split[0]] = split[1]
55 } 55 }
56 56
57 for key, expected := range expectedMap { 57 for key, expected := range expectedMap {
58 if got := m[key]; got != expected { 58 if got := m[key]; got != expected {
59 t.Errorf("for key %q got %q; expected %q", key, got, exp ected) 59 t.Errorf("for key %q got %q; expected %q", key, got, exp ected)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 Path: "testdata/test.cgi", 294 Path: "testdata/test.cgi",
295 Root: "/test.cgi", 295 Root: "/test.cgi",
296 PathLocationHandler: baseHandler, 296 PathLocationHandler: baseHandler,
297 } 297 }
298 expectedMap := map[string]string{ 298 expectedMap := map[string]string{
299 "basepath": "/foo", 299 "basepath": "/foo",
300 "remoteaddr": "1.2.3.4", 300 "remoteaddr": "1.2.3.4",
301 } 301 }
302 runCgiTest(t, h, "GET /test.cgi?loc=/foo HTTP/1.0\nHost: example.com\n\n ", expectedMap) 302 runCgiTest(t, h, "GET /test.cgi?loc=/foo HTTP/1.0\nHost: example.com\n\n ", expectedMap)
303 } 303 }
LEFTRIGHT

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