1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00
revive/test/file-header_test.go

44 lines
1.0 KiB
Go
Raw Normal View History

2018-02-05 00:51:19 +02:00
package test
import (
"testing"
"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
)
func TestLintFileHeader(t *testing.T) {
testRule(t, "lint-file-header1", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"foobar"},
2018-02-05 00:51:19 +02:00
})
testRule(t, "lint-file-header2", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"foobar"},
2018-02-05 00:51:19 +02:00
})
testRule(t, "lint-file-header3", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"foobar"},
2018-02-05 00:51:19 +02:00
})
testRule(t, "lint-file-header4", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"^\\sfoobar$"},
2018-02-05 00:51:19 +02:00
})
testRule(t, "lint-file-header5", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"^\\sfoo.*bar$"},
2018-02-05 00:51:19 +02:00
})
testRule(t, "lint-file-header6", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"foobar"},
})
}
func BenchmarkLintFileHeader(b *testing.B) {
2019-11-28 05:19:08 +02:00
var t *testing.T
for i := 0; i <= b.N; i++ {
testRule(t, "lint-file-header1", &rule.FileHeaderRule{}, &lint.RuleConfig{
Arguments: []any{"foobar"},
2019-11-28 05:19:08 +02:00
})
}
2018-02-05 00:51:19 +02:00
}