From fc43138a0ea5da02923ad36cbb8d2538f44f6ccc Mon Sep 17 00:00:00 2001 From: jialulu Date: Sun, 9 Feb 2025 22:23:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20fix=20slice=5Ftest.go=20,We=20should=20n?= =?UTF-8?q?ot=20assume=20the=20order=20of=20the=20slice=20when=20using=20m?= =?UTF-8?q?ultithreads=EF=BC=8Csort=20them=20before=20compare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slice/slice_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/slice/slice_test.go b/slice/slice_test.go index 9191c73..06d7f03 100644 --- a/slice/slice_test.go +++ b/slice/slice_test.go @@ -4,6 +4,7 @@ import ( "fmt" "math" "reflect" + "sort" "strconv" "strings" "sync" @@ -1794,6 +1795,8 @@ func TestFilterConcurrent(t *testing.T) { nums := []int{1, 2, 3, 4, 5, 6} expected := []int{4, 5, 6} actual := FilterConcurrent(nums, func(_, n int) bool { return n > 3 }, 4) + sort.Ints(actual) + sort.Ints(expected) assert.Equal(expected, actual) }) }