You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
t.Errorf("expected %q to parse, but got error %v", str, err)
135
135
}
136
+
ifaddr, err:=ParseIPAsIPNet(str)
137
+
iferr!=nil {
138
+
t.Errorf("expected %q to parse via ParseIPAsIPNet, but got error %v", str, err)
139
+
}
140
+
141
+
iftc.ifaddr {
142
+
// The test case expects ParseIPNet and
143
+
// ParseIPAsIPNet to parse to different values.
144
+
ifipnet.String() ==ifaddr.String() {
145
+
t.Errorf("expected %q to parse differently with ParseIPNet and ParseIPAsIPNet but got %q for both", str, ipnet.String())
146
+
}
147
+
// In this case, it's the ParseIPAsIPNet value
148
+
// that should re-stringify correctly. (ParseIPNet
149
+
// will have discarded the trailing bits.)
150
+
ipnet=ifaddr
151
+
} else {
152
+
// Some strings might parse to the same value and
153
+
// others might parse to different values.
154
+
// However, in all cases, the ParseIPAsIPNet value
155
+
// should be the same as the ParseIPNet value
156
+
// after masking it.
157
+
if!ipnet.IP.Equal(ifaddr.IP.Mask(ifaddr.Mask)) {
158
+
t.Errorf("expected %q to parse similarly with ParseIPNet and ParseIPAsIPNet but got IPs %q and %q->%q", str, ipnet.IP, ifaddr, ifaddr.IP.Mask(ifaddr.Mask))
159
+
}
160
+
}
161
+
136
162
ifipnet.String() !=tc.ipnets[0].String() {
137
163
t.Errorf("expected string %d %q to parse and re-stringify to %q but got %q", i+1, str, tc.ipnets[0].String(), ipnet.String())
0 commit comments