Skip to content

Commit 1910d66

Browse files
committed
Add parse error case
1 parent 565ccd0 commit 1910d66

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/net/url/url_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,12 @@ func TestJoinPath(t *testing.T) {
21002100
out: "https://go.googlesource.com/go/a/b/c",
21012101
err: false,
21022102
},
2103+
{
2104+
base: "http://[fe80::1%en0]:8080/",
2105+
elem: []string{"/go"},
2106+
out: "",
2107+
err: true,
2108+
},
21032109
}
21042110
for _, tt := range tests {
21052111
if out, err := JoinPath(tt.base, tt.elem...); out != tt.out || (err != nil) != tt.err {
@@ -2109,17 +2115,18 @@ func TestJoinPath(t *testing.T) {
21092115
}
21102116
t.Errorf("JoinPath(%q, %q) = %q, %v, want %q, %v", tt.base, tt.elem, out, err, tt.out, wantErr)
21112117
}
2118+
var out string
21122119
u, err := Parse(tt.base)
21132120
if err == nil {
21142121
u = u.JoinPath(tt.elem...)
2122+
out = u.String()
21152123
}
2116-
out := u.String()
21172124
if out != tt.out || (err != nil) != tt.err {
21182125
wantErr := "nil"
21192126
if tt.err {
21202127
wantErr = "non-nil error"
21212128
}
2122-
t.Errorf("JoinPath(%q, %q) = %q, %v, want %q, %v", tt.base, tt.elem, out, err, tt.out, wantErr)
2129+
t.Errorf("Parse(%q).JoinPath(%q) = %q, %v, want %q, %v", tt.base, tt.elem, out, err, tt.out, wantErr)
21232130
}
21242131
}
21252132
}

0 commit comments

Comments
 (0)