File tree Expand file tree Collapse file tree 6 files changed +14
-17
lines changed Expand file tree Collapse file tree 6 files changed +14
-17
lines changed Original file line number Diff line number Diff line change 55 "reflect"
66)
77
8-
98func validateOut (output reflect.Value ) error {
109 zeroValue := reflect.Value {}
1110 if output == zeroValue {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
1414// Validations:
1515//
1616// 1. Input and Output's slice should be of same type
17- // 2. Predicate function can take one argment and return one argument
17+ // 2. Predicate function can take one argument and return one argument
1818// 3. Predicate's return argument is always boolean.
1919// 4. Predicate's input argument should be input/output slice's element type.
2020//
Original file line number Diff line number Diff line change @@ -23,23 +23,22 @@ func TestFilter(t *testing.T) {
2323
2424 t .Run ("should struct types" , func (t * testing.T ) {
2525 type person struct {
26- name string
27- age int
26+ age int
2827 }
2928 input := []person {
30- {"john" , 30 },
31- {"doe" , 20 },
32- {"foo" , 40 },
33- {"bar" , 10 },
29+ {30 },
30+ {20 },
31+ {40 },
32+ {10 },
3433 }
3534 var output []person
3635
3736 err := godash .Filter (input , & output , func (p person ) bool {
3837 return p .age > 20
3938 })
4039 expected := []person {
41- {"john" , 30 },
42- {"foo" , 40 },
40+ {30 },
41+ {40 },
4342 }
4443
4544 assert .NoError (t , err )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
22github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
33github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
44github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
5+ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4 =
56github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
67github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk =
78github.com/stretchr/testify v1.4.0 /go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4 =
Original file line number Diff line number Diff line change @@ -24,12 +24,11 @@ func TestMap(t *testing.T) {
2424 t .Run ("support structs" , func (t * testing.T ) {
2525 type person struct {
2626 name string
27- age int
2827 }
2928
3029 in := []person {
31- {name : "john" , age : 20 },
32- {name : "doe" , age : 23 },
30+ {name : "john" },
31+ {name : "doe" },
3332 }
3433 out := make ([]string , 0 )
3534 expected := []string {"john" , "doe" }
Original file line number Diff line number Diff line change @@ -56,13 +56,12 @@ func TestReduce(t *testing.T) {
5656
5757 t .Run ("support structs" , func (t * testing.T ) {
5858 type person struct {
59- name string
60- age int
59+ age int
6160 }
6261
6362 in := []person {
64- {name : "john" , age : 20 },
65- {name : "doe" , age : 23 },
63+ {age : 20 },
64+ {age : 23 },
6665 }
6766 out := 0
6867 expected := 43
You can’t perform that action at this time.
0 commit comments