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>
diff --git a/unix/dirent_test.go b/unix/dirent_test.go
index f209fa1..ce80488 100644
--- a/unix/dirent_test.go
+++ b/unix/dirent_test.go
@@ -12,7 +12,7 @@
"os"
"path/filepath"
"runtime"
- "sort"
+ "slices"
"strconv"
"strings"
"testing"
@@ -72,7 +72,7 @@
}
}
- sort.Strings(names)
+ slices.Sort(names)
t.Logf("names: %q", names)
if len(names) != 10 {
@@ -145,9 +145,9 @@
}
// Check results
- sort.Strings(files)
- sort.Strings(files2)
- if strings.Join(files, "|") != strings.Join(files2, "|") {
+ slices.Sort(files)
+ slices.Sort(files2)
+ if !slices.Equal(files, files2) {
t.Errorf("bad file list: want\n%q\ngot\n%q", files, files2)
}
}
diff --git a/unix/getdirentries_test.go b/unix/getdirentries_test.go
index ca94a4c..c8a184b 100644
--- a/unix/getdirentries_test.go
+++ b/unix/getdirentries_test.go
@@ -10,8 +10,7 @@
"fmt"
"os"
"path/filepath"
- "sort"
- "strings"
+ "slices"
"testing"
"golang.org/x/sys/unix"
@@ -71,9 +70,9 @@
}
}
- sort.Strings(names)
- sort.Strings(names2)
- if strings.Join(names, ":") != strings.Join(names2, ":") {
+ slices.Sort(names)
+ slices.Sort(names2)
+ if !slices.Equal(names, names2) {
t.Errorf("names don't match\n names: %q\nnames2: %q", names, names2)
}
}