|
5 | 5 | package rphys_test
|
6 | 6 |
|
7 | 7 | import (
|
| 8 | + "strings" |
8 | 9 | "testing"
|
9 | 10 |
|
| 11 | + "github.com/google/go-cmp/cmp" |
| 12 | + "go-hep.org/x/hep/groot/rcmd" |
10 | 13 | "go-hep.org/x/hep/groot/rphys"
|
11 | 14 | )
|
12 | 15 |
|
@@ -82,5 +85,42 @@ func TestLorentzVector(t *testing.T) {
|
82 | 85 | }
|
83 | 86 | })
|
84 | 87 | }
|
| 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 | + } |
85 | 119 |
|
| 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 | + } |
86 | 126 | }
|
0 commit comments