mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
add testing.FailNow and related function to unreachable check (#711)
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
This commit is contained in:
23
testdata/unreachable-code.go
vendored
23
testdata/unreachable-code.go
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func foo() int {
|
||||
@@ -35,3 +36,25 @@ func g() {
|
||||
|
||||
fmt.Println("Bye, playground")
|
||||
}
|
||||
|
||||
func TestA(t *testing.T) {
|
||||
tests := make([]int, 100)
|
||||
for i := range tests {
|
||||
println("i: ", i)
|
||||
if i == 0 {
|
||||
t.Fatal("i == 0") // MATCH /unreachable code after this statement/
|
||||
println("unreachable")
|
||||
continue
|
||||
}
|
||||
if i == 1 {
|
||||
t.Fatalf("i:%d", i) // MATCH /unreachable code after this statement/
|
||||
println("unreachable")
|
||||
continue
|
||||
}
|
||||
if i == 2 {
|
||||
t.FailNow() // MATCH /unreachable code after this statement/
|
||||
println("unreachable")
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user