LEFT | RIGHT |
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 "fmt" | 8 "fmt" |
9 "os" | 9 "os" |
10 "reflect" | 10 "reflect" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 501 } |
502 | 502 |
503 func TestUnescapeUserinfo(t *testing.T) { | 503 func TestUnescapeUserinfo(t *testing.T) { |
504 for _, tt := range userinfoTests { | 504 for _, tt := range userinfoTests { |
505 if user, pass, err := UnescapeUserinfo(tt.Raw); user != tt.User
|| pass != tt.Password || err != nil { | 505 if user, pass, err := UnescapeUserinfo(tt.Raw); user != tt.User
|| pass != tt.Password || err != nil { |
506 t.Errorf("UnescapeUserinfo(%q) = %q, %q, %v, want %q, %q
, nil", tt.Raw, user, pass, err, tt.User, tt.Password) | 506 t.Errorf("UnescapeUserinfo(%q) = %q, %q, %v, want %q, %q
, nil", tt.Raw, user, pass, err, tt.User, tt.Password) |
507 } | 507 } |
508 } | 508 } |
509 } | 509 } |
510 | 510 |
511 type qMap map[string][]interface{} | 511 type qMap map[string][]string |
512 | 512 |
513 type EncodeQueryTest struct { | 513 type EncodeQueryTest struct { |
514 m qMap | 514 m qMap |
515 expected string | 515 expected string |
516 } | 516 } |
517 | 517 |
518 var encodeQueryTests = []EncodeQueryTest{ | 518 var encodeQueryTests = []EncodeQueryTest{ |
519 {nil, ""}, | 519 {nil, ""}, |
520 {qMap{"q": {"puppies"}, "oe": {"utf8"}}, "q=puppies&oe=utf8"}, | 520 {qMap{"q": {"puppies"}, "oe": {"utf8"}}, "q=puppies&oe=utf8"}, |
521 » {qMap{"q": {"dogs", "&", 7}}, "q=dogs&q=%26&q=7"}, | 521 » {qMap{"q": {"dogs", "&", "7"}}, "q=dogs&q=%26&q=7"}, |
522 } | 522 } |
523 | 523 |
524 func TestEncodeQuery(t *testing.T) { | 524 func TestEncodeQuery(t *testing.T) { |
525 for _, tt := range encodeQueryTests { | 525 for _, tt := range encodeQueryTests { |
526 if q := EncodeQuery(tt.m); q != tt.expected { | 526 if q := EncodeQuery(tt.m); q != tt.expected { |
527 t.Errorf(`EncodeQuery(%+v) = %q, want %q`, tt.m, q, tt.e
xpected) | 527 t.Errorf(`EncodeQuery(%+v) = %q, want %q`, tt.m, q, tt.e
xpected) |
528 } | 528 } |
529 } | 529 } |
530 } | 530 } |
LEFT | RIGHT |