Initial commit of modash
This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
commit
a20530ddfd
20 changed files with 425 additions and 0 deletions
31
moslice/uniq_test.go
Normal file
31
moslice/uniq_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package moslice_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"lmika.dev/pkg/modash/moslice"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUniq(t *testing.T) {
|
||||
t.Run("should return a slice with unique elements", func(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
in []int
|
||||
want []int
|
||||
}{
|
||||
{in: nil, want: nil},
|
||||
{in: []int{}, want: []int{}},
|
||||
{in: []int{2}, want: []int{2}},
|
||||
{in: []int{1, 2}, want: []int{1, 2}},
|
||||
{in: []int{2, 2}, want: []int{2}},
|
||||
{in: []int{3, 1, 4, 2, 3, 5, 1, 4}, want: []int{3, 1, 4, 2, 5}},
|
||||
}
|
||||
|
||||
for i, s := range scenarios {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
assert.Equal(t, s.want, moslice.Uniq(s.in))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue