mirror of
https://github.com/mgechev/revive.git
synced 2024-11-24 08:32:22 +02:00
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
package lint
|
|
|
|
import "testing"
|
|
|
|
// TestIsGenerated tests isGenerated function.
|
|
func TestIsGenerated(t *testing.T) { //revive:disable-line:exported
|
|
tests := []struct {
|
|
source string
|
|
generated bool
|
|
}{
|
|
{"// Code Generated by some tool. DO NOT EDIT.", false},
|
|
{"// Code generated by some tool. DO NOT EDIT.", true},
|
|
{"// Code generated by some tool. DO NOT EDIT", false},
|
|
{"// Code generated DO NOT EDIT.", true},
|
|
{"// Code generated DO NOT EDIT.", false},
|
|
{"\t\t// Code generated by some tool. DO NOT EDIT.\npackage foo\n", false},
|
|
{"// Code generated by some tool. DO NOT EDIT.\npackage foo\n", true},
|
|
{"package foo\n// Code generated by some tool. DO NOT EDIT.\ntype foo int\n", true},
|
|
{"package foo\n // Code generated by some tool. DO NOT EDIT.\ntype foo int\n", false},
|
|
{"package foo\n// Code generated by some tool. DO NOT EDIT. \ntype foo int\n", false},
|
|
{"package foo\ntype foo int\n// Code generated by some tool. DO NOT EDIT.\n", true},
|
|
{"package foo\ntype foo int\n// Code generated by some tool. DO NOT EDIT.", true},
|
|
}
|
|
|
|
for i, test := range tests {
|
|
got := isGenerated([]byte(test.source))
|
|
if got != test.generated {
|
|
t.Errorf("test %d, isGenerated() = %v, want %v", i, got, test.generated)
|
|
}
|
|
}
|
|
}
|