From 907df56f868ee1740f39c211cc98ed33093f46ac Mon Sep 17 00:00:00 2001 From: dudaodong Date: Tue, 11 Jan 2022 20:27:06 +0800 Subject: [PATCH] update: make func comment consistent --- slice/slice.go | 2 +- slice/slice_test.go | 29 ++--------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/slice/slice.go b/slice/slice.go index 41c7dcd..03b5bae 100644 --- a/slice/slice.go +++ b/slice/slice.go @@ -156,7 +156,7 @@ func Count[T any](slice []T, fn func(index int, t T) bool) int { } // GroupBy iterate over elements of the slice, each element will be group by criteria, returns two slices -// The function signature should be func(int, value T) bool . +// The function signature should be func(index int, T) bool . func GroupBy[T any](slice []T, fn func(index int, t T) bool) ([]T, []T) { if fn == nil { diff --git a/slice/slice_test.go b/slice/slice_test.go index d4f0641..20a1e0f 100644 --- a/slice/slice_test.go +++ b/slice/slice_test.go @@ -381,8 +381,8 @@ func TestDifference(t *testing.T) { assert.Equal([]int{1, 2, 3}, Difference(s1, s2)) } -func TestSortByFieldDesc(t *testing.T) { - assert := internal.NewAssert(t, "TestSortByField") +func TestSortByField(t *testing.T) { + assert := internal.NewAssert(t, "TestWithout") type student struct { name string @@ -406,31 +406,6 @@ func TestSortByFieldDesc(t *testing.T) { assert.Equal(students, studentsOfSortByAge) } -func TestSortByFieldAsc(t *testing.T) { - assert := internal.NewAssert(t, "TestSortByField") - - type student struct { - name string - age int - } - students := []student{ - {"a", 10}, - {"b", 15}, - {"c", 5}, - {"d", 6}, - } - studentsOfSortByAge := []student{ - {"c", 5}, - {"d", 6}, - {"a", 10}, - {"b", 15}, - } - - err := SortByField(students, "age") - assert.IsNil(err) - - assert.Equal(students, studentsOfSortByAge) -} func TestWithout(t *testing.T) { assert := internal.NewAssert(t, "TestWithout")