-
Notifications
You must be signed in to change notification settings - Fork 26
/
generated_test.go
38 lines (33 loc) · 1.48 KB
/
generated_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2013 The Go Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd.
// Taken from https://github.com/golang/lint/blob/85993ffd0a6cd043291f3f63d45d656d97b165bd/lint_test.go
package scanner
import "testing"
func TestIsGenerated(t *testing.T) {
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)
}
}
}