2018-02-04 14:51:19 -08:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
|
|
"github.com/mgechev/revive/rule"
|
|
|
|
)
|
|
|
|
|
2024-11-20 21:19:17 +02:00
|
|
|
func TestLintFileHeaderDefault(t *testing.T) {
|
|
|
|
testRule(t, "lint_file_header_default", &rule.FileHeaderRule{}, &lint.RuleConfig{})
|
|
|
|
}
|
|
|
|
|
2018-02-04 14:51:19 -08:00
|
|
|
func TestLintFileHeader(t *testing.T) {
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header1", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"foobar"},
|
2018-02-04 14:51:19 -08:00
|
|
|
})
|
|
|
|
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header2", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"foobar"},
|
2018-02-04 14:51:19 -08:00
|
|
|
})
|
|
|
|
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header3", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"foobar"},
|
2018-02-04 14:51:19 -08:00
|
|
|
})
|
|
|
|
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header4", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"^\\sfoobar$"},
|
2018-02-04 14:51:19 -08:00
|
|
|
})
|
|
|
|
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header5", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"^\\sfoo.*bar$"},
|
2018-02-04 14:51:19 -08:00
|
|
|
})
|
2019-11-28 01:29:59 +07:00
|
|
|
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header6", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"foobar"},
|
2019-11-28 01:29:59 +07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkLintFileHeader(b *testing.B) {
|
2019-11-28 10:19:08 +07:00
|
|
|
var t *testing.T
|
|
|
|
for i := 0; i <= b.N; i++ {
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "lint_file_header1", &rule.FileHeaderRule{}, &lint.RuleConfig{
|
2023-09-24 08:44:02 +02:00
|
|
|
Arguments: []any{"foobar"},
|
2019-11-28 10:19:08 +07:00
|
|
|
})
|
|
|
|
}
|
2018-02-04 14:51:19 -08:00
|
|
|
}
|