errors.New, etc values are not expected to be compared by value but the change in errors#27 made them incomparable. Assert that various kinds of errors have a functional equality operator, even if the result of that equality is always false.
(t *testing.T)
| 229 | // various kinds of errors have a functional equality operator, even |
| 230 | // if the result of that equality is always false. |
| 231 | func TestErrorEquality(t *testing.T) { |
| 232 | vals := []error{ |
| 233 | nil, |
| 234 | io.EOF, |
| 235 | errors.New("EOF"), |
| 236 | New("EOF"), |
| 237 | Errorf("EOF"), |
| 238 | Wrap(io.EOF, "EOF"), |
| 239 | Wrapf(io.EOF, "EOF%d", 2), |
| 240 | WithMessage(nil, "whoops"), |
| 241 | WithMessage(io.EOF, "whoops"), |
| 242 | WithStack(io.EOF), |
| 243 | WithStack(nil), |
| 244 | } |
| 245 | |
| 246 | for i := range vals { |
| 247 | for j := range vals { |
| 248 | _ = vals[i] == vals[j] // mustn't panic |
| 249 | } |
| 250 | } |
| 251 | } |