-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils_test.go
78 lines (73 loc) · 1.51 KB
/
utils_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package eagolint
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIsGenerated(t *testing.T) {
generatedFileContents := []byte("// Code generated by Empedocles. DO NOT EDIT.")
generatedFileContentsGoBinData := []byte("// Code generated for package kubernetes by go-bindata DO NOT EDIT. (@generated)")
nonGeneratedFileContents := []byte("// This is not generated code.")
tests := []struct {
fileContents []byte
want bool
}{
{generatedFileContents, true},
{generatedFileContentsGoBinData, true},
{nonGeneratedFileContents, false},
}
for _, test := range tests {
got := isGenerated(test.fileContents)
assert.Equal(t, test.want, got)
}
}
func TestIsPunctuated(t *testing.T) {
tests := []struct {
line string
want bool
}{
{
line: "This is punctuated!",
want: true,
},
{
line: "This is punctuated!!!!",
want: true,
},
{
line: "Is this punctuated?",
want: true,
},
{
line: "This is punctuated.",
want: true,
},
{
line: "This is punctuated (because of the parentheses)",
want: true,
},
{
line: "This is punctuated [because of the brackets]",
want: true,
},
{
line: "This is punctuated {because of the brackets}",
want: true,
},
{
line: "This is not punctuated",
want: false,
},
{
line: "This is not punctuated. Because",
want: false,
},
{
line: "This is not punctuated!!!s",
want: false,
},
}
for _, test := range tests {
got := isPunctuated(test.line)
assert.Equal(t, test.want, got)
}
}