From ecada541268c911af0ea4e4e1d5b1b9ae9350f8a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 2 Oct 2025 14:23:26 +0200 Subject: [PATCH] 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 Reviewed-by: Florian Lehner Reviewed-by: Carlos Amedee Auto-Submit: Tobias Klauser LUCI-TryBot-Result: Go LUCI Reviewed-by: Sean Liao --- unix/dirent_test.go | 10 +++++----- unix/getdirentries_test.go | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/unix/dirent_test.go b/unix/dirent_test.go index f209fa1f..ce804888 100644 --- a/unix/dirent_test.go +++ b/unix/dirent_test.go @@ -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) } } diff --git a/unix/getdirentries_test.go b/unix/getdirentries_test.go index ca94a4cf..c8a184b5 100644 --- a/unix/getdirentries_test.go +++ b/unix/getdirentries_test.go @@ -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) } }