Commit 15cce227 authored by Nigel Tao's avatar Nigel Tao

exp/cookiejar: add a test for canonicalHost errors.

R=dr.volker.dobler
CC=golang-dev
https://golang.org/cl/7389048
parent 2c2934ee
...@@ -51,15 +51,26 @@ var canonicalHostTests = map[string]string{ ...@@ -51,15 +51,26 @@ var canonicalHostTests = map[string]string{
"[2001:4860:0:::68]:8080": "2001:4860:0:::68", "[2001:4860:0:::68]:8080": "2001:4860:0:::68",
"www.bücher.de": "www.xn--bcher-kva.de", "www.bücher.de": "www.xn--bcher-kva.de",
"www.example.com.": "www.example.com", "www.example.com.": "www.example.com",
"[bad.unmatched.bracket:": "error",
} }
func TestCanonicalHost(t *testing.T) { func TestCanonicalHost(t *testing.T) {
for h, want := range canonicalHostTests { for h, want := range canonicalHostTests {
got, _ := canonicalHost(h) got, err := canonicalHost(h)
if want == "error" {
if err == nil {
t.Errorf("%q: got nil error, want non-nil", h)
}
continue
}
if err != nil {
t.Errorf("%q: %v", h, err)
continue
}
if got != want { if got != want {
t.Errorf("%q: got %q, want %q", h, got, want) t.Errorf("%q: got %q, want %q", h, got, want)
continue
} }
// TODO handle errors
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment