Skip to content

Commit

Permalink
groot/rtree: add formula test for slices
Browse files Browse the repository at this point in the history
Fixes #736.
  • Loading branch information
sbinet committed May 28, 2020
1 parent 351d7f1 commit 5e98121
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion groot/rtree/formula_test.go
Expand Up @@ -112,6 +112,20 @@ func TestFormulaFunc(t *testing.T) {
branches: []string{"ArrU64"},
want: []interface{}{uint64(0), uint64(1)},
},
{
fname: "../testdata/leaves.root",
tname: "tree",
rvars: -1,
fct: func(x []float32) []float64 {
o := make([]float64, len(x))
for i, v := range x {
o[i] = float64(2 * v)
}
return o
},
branches: []string{"SliF32"},
want: []interface{}{[]float64{}, []float64{2}},
},
{
fname: "../testdata/leaves.root",
tname: "tree",
Expand Down Expand Up @@ -377,7 +391,7 @@ func TestFormulaFunc(t *testing.T) {

err = r.Read(func(ctx RCtx) error {
if got, want := reflect.ValueOf(form.Func()).Call(nil)[0].Interface(), tc.want[ctx.Entry]; !reflect.DeepEqual(got, want) {
return fmt.Errorf("entry[%d]: invalid form-eval:\ngot=%v (%T)\nwant=%v (%T)", ctx.Entry, got, got, want, want)
return fmt.Errorf("entry[%d]: invalid form-eval:\ngot= %v (%T)\nwant=%v (%T)", ctx.Entry, got, got, want, want)
}

return nil
Expand Down

0 comments on commit 5e98121

Please sign in to comment.