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>
This commit is contained in:
Tobias Klauser
2025-10-02 14:23:26 +02:00
committed by Gopher Robot
parent 5e63aa5e0f
commit ecada54126
2 changed files with 9 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"slices"
"strconv"
"strings"
"testing"
@@ -72,7 +72,7 @@ func TestDirent(t *testing.T) {
}
}
sort.Strings(names)
slices.Sort(names)
t.Logf("names: %q", names)
if len(names) != 10 {
@@ -145,9 +145,9 @@ func TestDirentRepeat(t *testing.T) {
}
// 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)
}
}

View File

@@ -10,8 +10,7 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"slices"
"testing"
"golang.org/x/sys/unix"
@@ -71,9 +70,9 @@ func testGetdirentries(t *testing.T, count int) {
}
}
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)
}
}