mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Replace usage of golang.org/x/exp/constraints with Go 1.22 cmp/slices. Update .golangci.yml to new v2 format and enable gofmt/goimports. Refactor imports and type constraints across codebase for consistency.
27 lines
499 B
Go
27 lines
499 B
Go
package underscore_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
u "github.com/rjNemo/underscore"
|
|
)
|
|
|
|
func TestFind(t *testing.T) {
|
|
want := 5
|
|
nums := []int{2, 4, 5, 6, 8, 0}
|
|
isOdd := func(n int) bool { return n%2 != 0 }
|
|
|
|
got, err := u.Find(nums, isOdd)
|
|
assert.Equal(t, want, got)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestNotFound(t *testing.T) {
|
|
nums := []int{2, 4, 6, 8, 0}
|
|
isOdd := func(n int) bool { return n%2 != 0 }
|
|
|
|
_, err := u.Find(nums, isOdd)
|
|
assert.Error(t, err)
|
|
}
|