1
0
mirror of https://github.com/mgechev/revive.git synced 2024-12-02 09:02:23 +02:00
revive/rule/utils_test.go
2024-11-28 08:47:10 +01:00

33 lines
739 B
Go

package rule
import (
"fmt"
"testing"
)
func TestIsCallToExitFunction(t *testing.T) {
tests := []struct {
pkgName string
functionName string
expected bool
}{
{"os", "Exit", true},
{"syscall", "Exit", true},
{"log", "Fatal", true},
{"log", "Fatalf", true},
{"log", "Fatalln", true},
{"log", "Panic", true},
{"log", "Panicf", true},
{"log", "Print", false},
{"fmt", "Errorf", false},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("%s.%s", tt.pkgName, tt.functionName), func(t *testing.T) {
if got := isCallToExitFunction(tt.pkgName, tt.functionName); got != tt.expected {
t.Errorf("isCallToExitFunction(%s, %s) = %v; want %v", tt.pkgName, tt.functionName, got, tt.expected)
}
})
}
}