@@ -2068,51 +2068,43 @@ func TestJoinPath(t *testing.T) {
2068
2068
base string
2069
2069
elem []string
2070
2070
out string
2071
- err bool
2072
2071
}{
2073
2072
{
2074
2073
base : "https://go.googlesource.com" ,
2075
2074
elem : []string {"go" },
2076
2075
out : "https://go.googlesource.com/go" ,
2077
- err : false ,
2078
2076
},
2079
2077
{
2080
2078
base : "https://go.googlesource.com/a/b/c" ,
2081
2079
elem : []string {"../../../go" },
2082
2080
out : "https://go.googlesource.com/go" ,
2083
- err : false ,
2084
2081
},
2085
2082
{
2086
2083
base : "https://go.googlesource.com/" ,
2087
2084
elem : []string {"./go" },
2088
2085
out : "https://go.googlesource.com/go" ,
2089
- err : false ,
2090
2086
},
2091
2087
{
2092
2088
base : "https://go.googlesource.com//" ,
2093
2089
elem : []string {"/go" },
2094
2090
out : "https://go.googlesource.com/go" ,
2095
- err : false ,
2096
2091
},
2097
2092
{
2098
2093
base : "https://go.googlesource.com//" ,
2099
2094
elem : []string {"/go" , "a" , "b" , "c" },
2100
2095
out : "https://go.googlesource.com/go/a/b/c" ,
2101
- err : false ,
2102
2096
},
2103
2097
{
2104
2098
base : "http://[fe80::1%en0]:8080/" ,
2105
2099
elem : []string {"/go" },
2106
- out : "" ,
2107
- err : true ,
2108
2100
},
2109
2101
}
2110
2102
for _ , tt := range tests {
2111
- if out , err := JoinPath ( tt . base , tt . elem ... ); out != tt . out || ( err != nil ) != tt . err {
2112
- wantErr := "nil"
2113
- if tt . err {
2114
- wantErr = "non-nil error"
2115
- }
2103
+ wantErr := " nil"
2104
+ if tt . out == "" {
2105
+ wantErr = "non-nil error"
2106
+ }
2107
+ if out , err := JoinPath ( tt . base , tt . elem ... ); out != tt . out || ( err == nil ) != ( tt . out != "" ) {
2116
2108
t .Errorf ("JoinPath(%q, %q) = %q, %v, want %q, %v" , tt .base , tt .elem , out , err , tt .out , wantErr )
2117
2109
}
2118
2110
var out string
@@ -2121,11 +2113,7 @@ func TestJoinPath(t *testing.T) {
2121
2113
u = u .JoinPath (tt .elem ... )
2122
2114
out = u .String ()
2123
2115
}
2124
- if out != tt .out || (err != nil ) != tt .err {
2125
- wantErr := "nil"
2126
- if tt .err {
2127
- wantErr = "non-nil error"
2128
- }
2116
+ if out != tt .out || (err == nil ) != (tt .out != "" ) {
2129
2117
t .Errorf ("Parse(%q).JoinPath(%q) = %q, %v, want %q, %v" , tt .base , tt .elem , out , err , tt .out , wantErr )
2130
2118
}
2131
2119
}
0 commit comments