Skip to content

Commit

Permalink
thoas#50 Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vellotis committed Mar 10, 2021
1 parent a365a2b commit 442500c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions chain_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,11 @@ func TestChainReduce(t *testing.T) {
ReduceFunc: '*',
Acc: 1,
},
{
In: []string{"1", "2", "3", "4"},
ReduceFunc: func(acc string, elem string) string { return acc + elem },
Acc: "",
},
}

for idx, tc := range testCases {
Expand Down
5 changes: 5 additions & 0 deletions lazy_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,11 @@ func TestLazyReduce(t *testing.T) {
ReduceFunc: '*',
Acc: 1,
},
{
In: []string{"1", "2", "3", "4"},
ReduceFunc: func(acc string, elem string) string { return acc + elem },
Acc: "",
},
}

for idx, tc := range testCases {
Expand Down
14 changes: 10 additions & 4 deletions reduce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ func TestReduce(t *testing.T) {
Arr interface{}
Func interface{}
Acc interface{}
Result float64
Result interface{}
}{
{
[]int{1, 2, 3, 4},
func(acc, elem int) int { return acc + elem },
func(acc, elem float64) float64 { return acc + elem },
0,
float64(10),
},
{
&[]int16{1, 2, 3, 4},
'+',
5,
float64(15),
int16(15),
},
{
[]float64{1.1, 2.2, 3.3},
Expand All @@ -36,14 +36,20 @@ func TestReduce(t *testing.T) {
&[]int{1, 2, 3, 5},
func(acc int8, elem int16) int32 { return int32(acc) * int32(elem) },
1,
float64(30),
int32(30),
},
{
[]interface{}{1, 2, 3.3, 4},
'*',
1,
float64(26.4),
},
{
[]string{"1", "2", "3", "4"},
func(acc string, elem string) string { return acc + elem },
"",
"1234",
},
}

for idx, test := range testCases {
Expand Down

0 comments on commit 442500c

Please sign in to comment.