Skip to content

Commit d2842c5

Browse files
triariuspolyfloyd
authored andcommitted
test: regression test for #50
1 parent 40fde69 commit d2842c5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package issues
2+
3+
// Regression test for: https://github.com/polyfloyd/go-errorlint/issues/50
4+
5+
type AssertError struct {
6+
reason string
7+
}
8+
9+
func (e *AssertError) Error() string {
10+
return e.reason
11+
}
12+
13+
func (e *AssertError) Is(target error) bool {
14+
terr, ok := target.(*AssertError)
15+
return ok && terr.reason == e.reason
16+
}
17+
18+
type SwitchError struct {
19+
reason string
20+
}
21+
22+
func (e *SwitchError) Error() string {
23+
return e.reason
24+
}
25+
26+
func (e *SwitchError) Is(target error) bool {
27+
switch terr := target.(type) {
28+
case *SwitchError:
29+
return terr.reason == e.reason
30+
default:
31+
return false
32+
}
33+
}

0 commit comments

Comments
 (0)