mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-17 11:12:28 +08:00
refactoring: rename param and change its order
This commit is contained in:
@@ -1509,10 +1509,9 @@ func TestUniqueByConcurrent(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestUniqueByConcurrent")
|
||||
|
||||
nums := []int{1, 2, 3, 1, 2, 4, 5, 6, 4, 7}
|
||||
numOfThreads := 4
|
||||
comparator := func(item int, other int) bool { return item == other }
|
||||
|
||||
result := UniqueByConcurrent(nums, numOfThreads, comparator)
|
||||
result := UniqueByConcurrent(nums, comparator, 4)
|
||||
|
||||
assert.Equal([]int{1, 2, 3, 4, 5, 6, 7}, result)
|
||||
}
|
||||
@@ -1523,21 +1522,21 @@ func TestMapConcurrent(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestMapConcurrent")
|
||||
|
||||
t.Run("empty slice", func(t *testing.T) {
|
||||
actual := MapConcurrent([]int{}, 4, func(_, n int) int { return n * n })
|
||||
actual := MapConcurrent([]int{}, func(_, n int) int { return n * n }, 4)
|
||||
assert.Equal([]int{}, actual)
|
||||
})
|
||||
|
||||
t.Run("single thread", func(t *testing.T) {
|
||||
nums := []int{1, 2, 3, 4, 5, 6}
|
||||
expected := []int{1, 4, 9, 16, 25, 36}
|
||||
actual := MapConcurrent(nums, 1, func(_, n int) int { return n * n })
|
||||
actual := MapConcurrent(nums, func(_, n int) int { return n * n }, 1)
|
||||
assert.Equal(expected, actual)
|
||||
})
|
||||
|
||||
t.Run("multiple threads", func(t *testing.T) {
|
||||
nums := []int{1, 2, 3, 4, 5, 6}
|
||||
expected := []int{1, 4, 9, 16, 25, 36}
|
||||
actual := MapConcurrent(nums, 4, func(_, n int) int { return n * n })
|
||||
actual := MapConcurrent(nums, func(_, n int) int { return n * n }, 4)
|
||||
assert.Equal(expected, actual)
|
||||
})
|
||||
|
||||
@@ -1549,21 +1548,21 @@ func TestFilterConcurrent(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestFilterConcurrent")
|
||||
|
||||
t.Run("empty slice", func(t *testing.T) {
|
||||
actual := FilterConcurrent([]int{}, 4, func(_, n int) bool { return n != 0 })
|
||||
actual := FilterConcurrent([]int{}, func(_, n int) bool { return n != 0 }, 4)
|
||||
assert.Equal([]int{}, actual)
|
||||
})
|
||||
|
||||
t.Run("single thread", func(t *testing.T) {
|
||||
nums := []int{1, 2, 3, 4, 5, 6}
|
||||
expected := []int{4, 5, 6}
|
||||
actual := FilterConcurrent(nums, 1, func(_, n int) bool { return n > 3 })
|
||||
actual := FilterConcurrent(nums, func(_, n int) bool { return n > 3 }, 1)
|
||||
assert.Equal(expected, actual)
|
||||
})
|
||||
|
||||
t.Run("multiple threads", func(t *testing.T) {
|
||||
nums := []int{1, 2, 3, 4, 5, 6}
|
||||
expected := []int{4, 5, 6}
|
||||
actual := FilterConcurrent(nums, 4, func(_, n int) bool { return n > 3 })
|
||||
actual := FilterConcurrent(nums, func(_, n int) bool { return n > 3 }, 4)
|
||||
assert.Equal(expected, actual)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user