diff options
| author | jiahua wang <wjh180909@gmail.com> | 2023-04-08 20:42:26 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-04-18 13:37:52 +0000 |
| commit | b07b00565b0d06d521e7c7aee0897a6434157c0f (patch) | |
| tree | fc1b43ddbc2f33d58710a18cedd143f5b518558a /src | |
| parent | 14ab998f95b53baa6e336c598b0f34e319cc9717 (diff) | |
| download | go-b07b00565b0d06d521e7c7aee0897a6434157c0f.tar.xz | |
maps: replace slicesEqual with slices.Equal
Change-Id: I15aeef9c6d3ddc80644a14d6266d21a8515ede4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/483156
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/maps/maps_test.go | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/maps/maps_test.go b/src/maps/maps_test.go index 144f5375c9..1825df5b77 100644 --- a/src/maps/maps_test.go +++ b/src/maps/maps_test.go @@ -6,24 +6,12 @@ package maps import ( "math" + "slices" "sort" "strconv" "testing" ) -// TODO: replace with slices.Equal when slices is in GOROOT. -func slicesEqual[E comparable](s1, s2 []E) bool { - if len(s1) != len(s2) { - return false - } - for i := range s1 { - if s1[i] != s2[i] { - return false - } - } - return true -} - var m1 = map[int]int{1: 2, 2: 4, 4: 8, 8: 16} var m2 = map[int]string{1: "2", 2: "4", 4: "8", 8: "16"} @@ -32,13 +20,13 @@ func TestKeys(t *testing.T) { got1 := Keys(m1) sort.Ints(got1) - if !slicesEqual(got1, want) { + if !slices.Equal(got1, want) { t.Errorf("Keys(%v) = %v, want %v", m1, got1, want) } got2 := Keys(m2) sort.Ints(got2) - if !slicesEqual(got2, want) { + if !slices.Equal(got2, want) { t.Errorf("Keys(%v) = %v, want %v", m2, got2, want) } } @@ -47,14 +35,14 @@ func TestValues(t *testing.T) { got1 := Values(m1) want1 := []int{2, 4, 8, 16} sort.Ints(got1) - if !slicesEqual(got1, want1) { + if !slices.Equal(got1, want1) { t.Errorf("Values(%v) = %v, want %v", m1, got1, want1) } got2 := Values(m2) want2 := []string{"16", "2", "4", "8"} sort.Strings(got2) - if !slicesEqual(got2, want2) { + if !slices.Equal(got2, want2) { t.Errorf("Values(%v) = %v, want %v", m2, got2, want2) } } |
