1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-13 17:22:27 +08:00

Slice: Optimize slice func tools (#9)

IntSlice and StringSlice: preallocate memory up front for output slice.
Instead returning a error throw a panic because most likely it's a
programming error.
Contain: rename slice to iterableType and add default case for type
mismatches
This commit is contained in:
donutloop
2021-12-31 03:15:38 +01:00
committed by GitHub
parent 051f20caef
commit 147c1625b5
2 changed files with 32 additions and 24 deletions

View File

@@ -237,10 +237,8 @@ func TestIntSlice(t *testing.T) {
}
func intSlice(t *testing.T, test interface{}, expected []int) {
res, err := IntSlice(test)
if err != nil {
t.Error("IntSlice Error: " + err.Error())
}
res := IntSlice(test)
if !reflect.DeepEqual(res, expected) {
utils.LogFailedTestInfo(t, "IntSlice", test, expected, res)
t.FailNow()