2018-07-17 21:21:27 +02:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
|
|
"github.com/mgechev/revive/rule"
|
|
|
|
)
|
|
|
|
|
2024-11-18 15:38:56 +02:00
|
|
|
func TestAddConstantWithDefaultArguments(t *testing.T) {
|
|
|
|
testRule(t, "add_constant_default", &rule.AddConstantRule{}, &lint.RuleConfig{})
|
|
|
|
}
|
2018-07-17 21:21:27 +02:00
|
|
|
|
2024-11-18 15:38:56 +02:00
|
|
|
func TestAddConstantWithArguments(t *testing.T) {
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "add_constant", &rule.AddConstantRule{}, &lint.RuleConfig{
|
2024-11-18 15:38:56 +02:00
|
|
|
Arguments: []any{map[string]any{
|
|
|
|
"maxLitCount": "2",
|
|
|
|
"allowStrs": "\"\"",
|
|
|
|
"allowInts": "0,1,2",
|
|
|
|
"allowFloats": "0.0,1.0",
|
|
|
|
"ignoreFuncs": "os\\.(CreateFile|WriteFile|Chmod|FindProcess),\\.Println,ignoredFunc,\\.Info",
|
|
|
|
}},
|
2018-07-17 21:21:27 +02:00
|
|
|
})
|
2025-03-28 01:34:20 -07:00
|
|
|
testRule(t, "add_constant", &rule.AddConstantRule{}, &lint.RuleConfig{
|
|
|
|
Arguments: []any{map[string]any{
|
|
|
|
"max-lit-count": "2",
|
|
|
|
"allow-strs": `""`,
|
|
|
|
"allow-ints": "0,1,2",
|
|
|
|
"allow-floats": "0.0,1.0",
|
|
|
|
"ignore-funcs": `os\.(CreateFile|WriteFile|Chmod|FindProcess),\.Println,ignoredFunc,\.Info`,
|
|
|
|
}},
|
|
|
|
})
|
2018-07-17 21:21:27 +02:00
|
|
|
}
|