26 lines
550 B
Go
26 lines
550 B
Go
package moslice_test
|
|
|
|
import (
|
|
"lmika.dev/pkg/modash/moslice"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestContains(t *testing.T) {
|
|
var (
|
|
ints = []int{1, 2, 3}
|
|
strs = []string{"a", "b", "c"}
|
|
)
|
|
|
|
t.Run("should find items in the slice", func(t *testing.T) {
|
|
assert.True(t, moslice.Contains(ints, 2))
|
|
assert.True(t, moslice.Contains(strs, "c"))
|
|
})
|
|
|
|
t.Run("should return false if items not in slice", func(t *testing.T) {
|
|
assert.False(t, moslice.Contains(ints, 131))
|
|
assert.False(t, moslice.Contains(strs, "bla"))
|
|
})
|
|
}
|