mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +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:
1 parent
051f20caef
commit
147c1625b5
2 files changed
+32
-24
No files matched your search
+2
-4
@@ -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