Skip to content

Commit aff39b3

Browse files
committed
chore: update tests
1 parent a5053db commit aff39b3

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

pkg/golinters/gochecksumtype/testdata/gochecksumtype.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ func sumTypeTest() {
2929
panic("??")
3030
}
3131

32+
switch sum.(type) {
33+
case *One:
34+
default:
35+
log.Println("legit catch all goes here")
36+
}
37+
3238
log.Println("??")
3339

3440
switch sum.(type) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//golangcitest:args -Egochecksumtype
2+
//golangcitest:config_path testdata/gochecksumtype_custom.yml
3+
package testdata
4+
5+
import (
6+
"log"
7+
)
8+
9+
//sumtype:decl
10+
type SumType interface{ isSumType() }
11+
12+
//sumtype:decl
13+
type One struct{} // want "type 'One' is not an interface"
14+
15+
func (One) isSumType() {}
16+
17+
type Two struct{}
18+
19+
func (Two) isSumType() {}
20+
21+
func sumTypeTest() {
22+
var sum SumType = One{}
23+
switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
24+
case One:
25+
}
26+
27+
switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
28+
case One:
29+
default:
30+
panic("??")
31+
}
32+
33+
switch sum.(type) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
34+
case *One:
35+
default:
36+
log.Println("legit catch all goes here")
37+
}
38+
39+
log.Println("??")
40+
41+
switch sum.(type) {
42+
case One:
43+
case Two:
44+
}
45+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
linters-settings:
2+
gochecksumtype:
3+
default-signifies-exhaustive: false

0 commit comments

Comments
 (0)