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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user