Skip to content

Commit eaeb641

Browse files
committed
groot/rphys: test RStreamer with Bind+Unmarshaler for TLorentzVector
Updates #880.
1 parent 679c886 commit eaeb641

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

groot/rphys/lorentzvector_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
package rphys_test
66

77
import (
8+
"strings"
89
"testing"
910

11+
"github.com/google/go-cmp/cmp"
12+
"go-hep.org/x/hep/groot/rcmd"
1013
"go-hep.org/x/hep/groot/rphys"
1114
)
1215

@@ -82,5 +85,42 @@ func TestLorentzVector(t *testing.T) {
8285
}
8386
})
8487
}
88+
}
89+
90+
func TestLorentzVectorRStreamer(t *testing.T) {
91+
const (
92+
deep = true
93+
want = `key[000]: tlv;1 "A four vector with (-,-,-,+) metric" (TLorentzVector) => "TLorentzVector{P: {10, 20, 30}, E: 40}"
94+
key[001]: tree;1 "my tree title" (TTree)
95+
[000][p4]: {{0 50331648} {{0 50331648} 0 1 2} 3}
96+
[001][p4]: {{0 50331648} {{0 50331648} 1 2 3} 4}
97+
[002][p4]: {{0 50331648} {{0 50331648} 2 3 4} 5}
98+
[003][p4]: {{0 50331648} {{0 50331648} 3 4 5} 6}
99+
[004][p4]: {{0 50331648} {{0 50331648} 4 5 6} 7}
100+
[005][p4]: {{0 50331648} {{0 50331648} 5 6 7} 8}
101+
[006][p4]: {{0 50331648} {{0 50331648} 6 7 8} 9}
102+
[007][p4]: {{0 50331648} {{0 50331648} 7 8 9} 10}
103+
[008][p4]: {{0 50331648} {{0 50331648} 8 9 10} 11}
104+
[009][p4]: {{0 50331648} {{0 50331648} 9 10 11} 12}
105+
`
106+
)
107+
108+
for _, fname := range []string{
109+
"../testdata/tlv-split00.root", // exercizes T{Branch,Leaf}Object
110+
"../testdata/tlv-split01.root",
111+
"../testdata/tlv-split99.root",
112+
} {
113+
t.Run(fname, func(t *testing.T) {
114+
got := new(strings.Builder)
115+
err := rcmd.Dump(got, fname, deep, nil)
116+
if err != nil {
117+
t.Fatalf("could not run root-dump: %+v", err)
118+
}
85119

120+
if got, want := got.String(), want; got != want {
121+
diff := cmp.Diff(want, got)
122+
t.Fatalf("invalid root-dump output: -- (-ref +got)\n%s", diff)
123+
}
124+
})
125+
}
86126
}

0 commit comments

Comments
 (0)