Skip to content

Commit 8a2ca9c

Browse files
committed
options_test: Use slices.Equal rather than hand-rolling it
1 parent a7ce8e9 commit 8a2ca9c

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

cmd/multibuild/options_test.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,11 @@ func TestScanBuildPath(t *testing.T) {
180180
}
181181

182182
equalOptions := func(a, b options) bool {
183-
if len(a.Include) != len(b.Include) || len(a.Exclude) != len(b.Exclude) {
183+
if !slices.Equal(a.Include, b.Include) {
184184
return false
185185
}
186-
for i := range a.Include {
187-
if a.Include[i] != b.Include[i] {
188-
return false
189-
}
190-
}
191-
for i := range a.Exclude {
192-
if a.Exclude[i] != b.Exclude[i] {
193-
return false
194-
}
186+
if !slices.Equal(a.Exclude, b.Exclude) {
187+
return false
195188
}
196189
return true
197190
}
@@ -578,19 +571,7 @@ func TestValidateFormatString(t *testing.T) {
578571
t.Fatalf("unexpected error: %v", err)
579572
}
580573

581-
equalFormats := func(a, b []format) bool {
582-
if len(a) != len(b) {
583-
return false
584-
}
585-
for i := range a {
586-
if a[i] != b[i] {
587-
return false
588-
}
589-
}
590-
return true
591-
}
592-
593-
if !equalFormats(out, tt.outputs) {
574+
if !slices.Equal(out, tt.outputs) {
594575
t.Fatalf("output mismatch: got %q, want %q", out, tt.input)
595576
}
596577
})

0 commit comments

Comments
 (0)