Skip to content

Commit f05491e

Browse files
committed
[RF] Test schema evolution of RooDataHist from version 5 and 6
Extend the RooDataHist tests to also validate the schema evolution from version 5 and version 6. Version 6 is the current version, so the `dataHistv6_ref.root` reference file was produced with ROOT master. Version 5 was used in ROOT 6.24, which was used to produce the `dataHistv5_ref.root` reference file.
1 parent ef483dd commit f05491e

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

roofit/roofitcore/test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ ROOT_ADD_GTEST(simple simple.cxx LIBRARIES RooFitCore)
1010
ROOT_ADD_GTEST(testWorkspace testWorkspace.cxx LIBRARIES RooFitCore RooFit RooStats)
1111
if(NOT MSVC OR win_broken_tests)
1212
ROOT_ADD_GTEST(testRooDataHist testRooDataHist.cxx LIBRARIES RooFitCore
13-
COPY_TO_BUILDDIR ${CMAKE_CURRENT_SOURCE_DIR}/dataHistv4_ref.root)
13+
COPY_TO_BUILDDIR ${CMAKE_CURRENT_SOURCE_DIR}/dataHistv4_ref.root
14+
${CMAKE_CURRENT_SOURCE_DIR}/dataHistv5_ref.root
15+
${CMAKE_CURRENT_SOURCE_DIR}/dataHistv6_ref.root)
1416
endif()
1517
ROOT_ADD_GTEST(testRooSimPdfBuilder testRooSimPdfBuilder.cxx LIBRARIES RooFitCore RooFit)
1618
ROOT_ADD_GTEST(testRooWrapperPdf testRooWrapperPdf.cxx LIBRARIES Gpad RooFitCore)
8.55 KB
Binary file not shown.
8.52 KB
Binary file not shown.

roofit/roofitcore/test/testRooDataHist.cxx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,25 @@ TEST(RooDataHist, WeightedEntries)
180180
EXPECT_EQ(weight, weightBin10);
181181
}
182182

183-
TEST(RooDataHist, ReadV4Legacy)
184-
{
185-
TFile v4Ref("dataHistv4_ref.root");
186-
ASSERT_TRUE(v4Ref.IsOpen());
183+
class RooDataHistIO : public testing::TestWithParam<const char*> {
184+
public:
185+
void SetUp() override {
186+
TFile file(GetParam(), "READ");
187+
ASSERT_TRUE(file.IsOpen());
188+
189+
file.GetObject("dataHist", legacy);
190+
ASSERT_NE(legacy, nullptr);
191+
}
192+
193+
void TearDown() override {
194+
delete legacy;
195+
}
187196

188-
RooDataHist* legacy = nullptr;
189-
v4Ref.GetObject("dataHist", legacy);
190-
ASSERT_NE(legacy, nullptr);
197+
protected:
198+
RooDataHist* legacy{nullptr};
199+
};
200+
201+
TEST_P(RooDataHistIO, ReadLegacy) {
191202

192203
RooDataHist& dataHist = *legacy;
193204

@@ -239,6 +250,10 @@ TEST(RooDataHist, ReadV4Legacy)
239250
}
240251

241252

253+
INSTANTIATE_TEST_SUITE_P(IO_SchemaEvol, RooDataHistIO,
254+
testing::Values("dataHistv4_ref.root", "dataHistv5_ref.root", "dataHistv6_ref.root"));
255+
256+
242257
void fillHist(TH2D* histo, double content) {
243258
for (int i=0; i < histo->GetNbinsX()+2; ++i) {
244259
for (int j=0; j < histo->GetNbinsY()+2; ++j) {

0 commit comments

Comments
 (0)