diff --git a/groot/rjson/rjson_test.go b/groot/rjson/rjson_test.go index 7cba33c46..468e0f7d4 100644 --- a/groot/rjson/rjson_test.go +++ b/groot/rjson/rjson_test.go @@ -49,16 +49,54 @@ func TestMarshal(t *testing.T) { return rhist.NewH2DFrom(h) }, }, - // FIXME(sbinet) - // { - // name: "graph", - // gen: func() root.Object { - // s := hbook.NewS2DFrom([]float64{1, 2, 3}, []float64{2, 4, 6}) - // s.Annotation()["name"] = "s2" - // s.Annotation()["title"] = "my title" - // return rhist.NewGraphFrom(s) - // }, - // }, + { + name: "graph", + gen: func() root.Object { + s := hbook.NewS2DFrom([]float64{1, 2, 3}, []float64{2, 4, 6}) + s.Annotation()["name"] = "s2" + s.Annotation()["title"] = "my title" + return rhist.NewGraphFrom(s) + }, + }, + { + name: "tge", + gen: func() root.Object { + s := hbook.NewS2D([]hbook.Point2D{ + {X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}}, + {X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}}, + {X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}}, + }...) + s.Annotation()["name"] = "s2" + s.Annotation()["title"] = "my title" + return rhist.NewGraphErrorsFrom(s) + }, + }, + { + name: "tgae", + gen: func() root.Object { + s := hbook.NewS2D([]hbook.Point2D{ + {X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}}, + {X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}}, + {X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}}, + }...) + s.Annotation()["name"] = "s2" + s.Annotation()["title"] = "my title" + return rhist.NewGraphAsymmErrorsFrom(s) + }, + }, + { + name: "tgme", + gen: func() root.Object { + s := hbook.NewS2D([]hbook.Point2D{ + {X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}}, + {X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}}, + {X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}}, + }...) + s.Annotation()["name"] = "s2" + s.Annotation()["title"] = "my title" + return rhist.NewGraphMultiErrorsFrom(s) + }, + }, } { t.Run(tc.name, func(t *testing.T) { var ( diff --git a/groot/rjson/testdata/graph_golden.json b/groot/rjson/testdata/graph_golden.json new file mode 100644 index 000000000..5e1efbcc1 --- /dev/null +++ b/groot/rjson/testdata/graph_golden.json @@ -0,0 +1 @@ +{"_typename": "TGraph", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6} \ No newline at end of file diff --git a/groot/rjson/testdata/tgae_golden.json b/groot/rjson/testdata/tgae_golden.json new file mode 100644 index 000000000..13de4a220 --- /dev/null +++ b/groot/rjson/testdata/tgae_golden.json @@ -0,0 +1 @@ +{"_typename": "TGraphAsymmErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEXlow": [10,20,30], "fEXhigh": [20,30,40], "fEYlow": [11,12,13], "fEYhigh": [22,23,24]} \ No newline at end of file diff --git a/groot/rjson/testdata/tge_golden.json b/groot/rjson/testdata/tge_golden.json new file mode 100644 index 000000000..066be0818 --- /dev/null +++ b/groot/rjson/testdata/tge_golden.json @@ -0,0 +1 @@ +{"_typename": "TGraphErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEX": [10,20,30], "fEY": [11,12,13]} \ No newline at end of file diff --git a/groot/rjson/testdata/tgme_golden.json b/groot/rjson/testdata/tgme_golden.json new file mode 100644 index 000000000..fdffbd368 --- /dev/null +++ b/groot/rjson/testdata/tgme_golden.json @@ -0,0 +1 @@ +{"_typename": "TGraphMultiErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fNYErrors": 1, "fSumErrorsMode": 0, "fExL": [10,20,30], "fExH": [20,30,40], "fEyL": [[11,12,13]], "fEyH": [[22,23,24]], "fAttFill": [{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0}], "fAttLine": [{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0}]} \ No newline at end of file