Skip to content
Snippets Groups Projects
Commit 550550ae authored by Enrico Guiraud's avatar Enrico Guiraud
Browse files

[DF] Add test for TChain with TTrees with different names

parent 4ba47fde
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
#include <gtest/gtest.h>
#include <ROOT/RDataFrame.hxx>
#include <ROOT/TSeq.hxx>
#include <TChain.h>
#include <TFile.h>
#include <TGraph.h>
#include <TInterpreter.h>
......@@ -927,6 +928,28 @@ TEST(RDFSimpleTests, ScalarValuesCollectionWeights)
EXPECT_ANY_THROW(*h);
}
TEST_P(RDFSimpleTests, ChainWithDifferentTreeNames)
{
const auto fname1 = "test_chainwithdifferenttreenames_1.root";
const auto fname2 = "test_chainwithdifferenttreenames_2.root";
{
ROOT::RDataFrame(10).Define("x", [] { return 1; }).Snapshot<int>("t1", fname1, {"x"});
ROOT::RDataFrame(10).Define("x", [] { return 3; }).Snapshot<int>("t2", fname2, {"x"});
}
// add trees to chain
TChain c("t1");
c.Add(fname1);
c.Add((std::string(fname2) + "/t2").c_str());
// pass chain to RDF and process trees with different names
ROOT::RDataFrame df2(c);
EXPECT_DOUBLE_EQ(*df2.Mean("x"), 2);
gSystem->Unlink(fname1);
gSystem->Unlink(fname2);
}
// run single-thread tests
INSTANTIATE_TEST_CASE_P(Seq, RDFSimpleTests, ::testing::Values(false));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment