Skip to content

Commit 1a82395

Browse files
committed
[RDF] Add test carrying a Define across an input file boundary.
The code for updating branch addresses of TBranchElement instances was triggered only in the context of a Redefine. Here, a test with a Define is added to increase the coverage in snapshot with multiple input files.
1 parent d0df45d commit 1a82395

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tree/dataframe/test/dataframe_snapshot.cxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,31 @@ TEST_F(RDFSnapshotArrays, SingleThreadJitted)
506506
checkSnapshotArrayFile(dj, kNEvents);
507507
}
508508

509+
// Run a define across a TTree boundary to trigger an update of branch addresses
510+
TEST_F(RDFSnapshotArrays, AddDefine)
511+
{
512+
RDataFrame df("arrayTree", kFileNames);
513+
auto df2 = df.Define("RVecColumn",
514+
[](ULong64_t entry) {
515+
return ROOT::RVec<ULong64_t>{entry, entry + 1, entry + 2, entry + 3, entry + 4, entry + 5};
516+
},
517+
{"rdfentry_"})
518+
.Snapshot("t", "test_snapshotDefineRVec.root", {"RVecColumn"});
519+
df2->Foreach(
520+
[](const ROOT::RVec<ULong64_t> &v, ULong64_t entry) {
521+
EXPECT_EQ(v.size(), 6);
522+
EXPECT_FLOAT_EQ(v.front(), entry);
523+
524+
std::vector<ULong64_t> column(v.begin(), v.end());
525+
std::vector<ULong64_t> target(6);
526+
std::generate(target.begin(), target.end(), [i = entry]() mutable { return i++; });
527+
EXPECT_EQ(column, target);
528+
},
529+
{"RVecColumn", "rdfentry_"});
530+
531+
gSystem->Unlink("test_snapshotDefineRVec.root.root");
532+
}
533+
509534
TEST_F(RDFSnapshotArrays, RedefineArray)
510535
{
511536
static constexpr unsigned int newArraySize = 6u;

0 commit comments

Comments
 (0)