Skip to content

Commit ecada54

Browse files
tklausergopherbot
authored andcommitted
unix: use slices.{Equal,Sort} in tests
Same as CL 587655 and CL 690475 did for package syscall tests. Change-Id: Ie3c8726a4e2c859b5d7992ea1baec14083b9fdba Reviewed-on: https://go-review.googlesource.com/c/sys/+/708558 Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev>
1 parent 5e63aa5 commit ecada54

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

unix/dirent_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"os"
1313
"path/filepath"
1414
"runtime"
15-
"sort"
15+
"slices"
1616
"strconv"
1717
"strings"
1818
"testing"
@@ -72,7 +72,7 @@ func TestDirent(t *testing.T) {
7272
}
7373
}
7474

75-
sort.Strings(names)
75+
slices.Sort(names)
7676
t.Logf("names: %q", names)
7777

7878
if len(names) != 10 {
@@ -145,9 +145,9 @@ func TestDirentRepeat(t *testing.T) {
145145
}
146146

147147
// Check results
148-
sort.Strings(files)
149-
sort.Strings(files2)
150-
if strings.Join(files, "|") != strings.Join(files2, "|") {
148+
slices.Sort(files)
149+
slices.Sort(files2)
150+
if !slices.Equal(files, files2) {
151151
t.Errorf("bad file list: want\n%q\ngot\n%q", files, files2)
152152
}
153153
}

unix/getdirentries_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
"fmt"
1111
"os"
1212
"path/filepath"
13-
"sort"
14-
"strings"
13+
"slices"
1514
"testing"
1615

1716
"golang.org/x/sys/unix"
@@ -71,9 +70,9 @@ func testGetdirentries(t *testing.T, count int) {
7170
}
7271
}
7372

74-
sort.Strings(names)
75-
sort.Strings(names2)
76-
if strings.Join(names, ":") != strings.Join(names2, ":") {
73+
slices.Sort(names)
74+
slices.Sort(names2)
75+
if !slices.Equal(names, names2) {
7776
t.Errorf("names don't match\n names: %q\nnames2: %q", names, names2)
7877
}
7978
}

0 commit comments

Comments
 (0)