You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: makezero/makezero_test.go
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,46 @@ func foo() {
79
79
})
80
80
}
81
81
82
+
funcTestMultiDeclare(t*testing.T) {
83
+
t.Run("handles multi declares in same line", func(t*testing.T) {
84
+
t.Run("with just first obj is non-zero", func(t*testing.T) {
85
+
linter:=NewLinter(false)
86
+
expectIssues(t, linter, `
87
+
package bar
88
+
89
+
func foo() {
90
+
a, b := make([]int, 10), make([]int, 0)
91
+
a = append(a, 10)
92
+
b = append(b, 10)
93
+
}`, "append to slice `a` with non-zero initialized length at testing.go:6:9")
94
+
})
95
+
96
+
t.Run("with just second obj is non-zero", func(t*testing.T) {
97
+
linter:=NewLinter(false)
98
+
expectIssues(t, linter, `
99
+
package bar
100
+
101
+
func foo() {
102
+
a, b := make([]int, 0), make([]int, 10)
103
+
a = append(a, 10)
104
+
b = append(b, 10)
105
+
}`, "append to slice `b` with non-zero initialized length at testing.go:7:9")
106
+
})
107
+
108
+
t.Run("with all obj non-zero", func(t*testing.T) {
109
+
linter:=NewLinter(false)
110
+
expectIssues(t, linter, `
111
+
package bar
112
+
113
+
func foo() {
114
+
a, b := make([]int, 10), make([]int, 10)
115
+
a = append(a, 10)
116
+
b = append(b, 10)
117
+
}`, "append to slice `a` with non-zero initialized length at testing.go:6:9", "append to slice `b` with non-zero initialized length at testing.go:7:9")
0 commit comments