diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go index 8779ee209d..84dba45c3c 100644 --- a/src/net/url/url_test.go +++ b/src/net/url/url_test.go @@ -2068,51 +2068,43 @@ func TestJoinPath(t *testing.T) { base string elem []string out string - err bool }{ { base: "https://go.googlesource.com", elem: []string{"go"}, out: "https://go.googlesource.com/go", - err: false, }, { base: "https://go.googlesource.com/a/b/c", elem: []string{"../../../go"}, out: "https://go.googlesource.com/go", - err: false, }, { base: "https://go.googlesource.com/", elem: []string{"./go"}, out: "https://go.googlesource.com/go", - err: false, }, { base: "https://go.googlesource.com//", elem: []string{"/go"}, out: "https://go.googlesource.com/go", - err: false, }, { base: "https://go.googlesource.com//", elem: []string{"/go", "a", "b", "c"}, out: "https://go.googlesource.com/go/a/b/c", - err: false, }, { base: "http://[fe80::1%en0]:8080/", elem: []string{"/go"}, - out: "", - err: true, }, } for _, tt := range tests { - if out, err := JoinPath(tt.base, tt.elem...); out != tt.out || (err != nil) != tt.err { - wantErr := "nil" - if tt.err { - wantErr = "non-nil error" - } + wantErr := "nil" + if tt.out == "" { + wantErr = "non-nil error" + } + if out, err := JoinPath(tt.base, tt.elem...); out != tt.out || (err == nil) != (tt.out != "") { t.Errorf("JoinPath(%q, %q) = %q, %v, want %q, %v", tt.base, tt.elem, out, err, tt.out, wantErr) } var out string @@ -2121,11 +2113,7 @@ func TestJoinPath(t *testing.T) { u = u.JoinPath(tt.elem...) out = u.String() } - if out != tt.out || (err != nil) != tt.err { - wantErr := "nil" - if tt.err { - wantErr = "non-nil error" - } + if out != tt.out || (err == nil) != (tt.out != "") { t.Errorf("Parse(%q).JoinPath(%q) = %q, %v, want %q, %v", tt.base, tt.elem, out, err, tt.out, wantErr) } }