From 1748a80e84b5063ef35d2f57bcaa5fa3539221bf Mon Sep 17 00:00:00 2001 From: Vincenzo Eduardo Padulano Date: Tue, 3 Oct 2023 17:15:18 +0200 Subject: [PATCH] [df] Add regression test for #12043 --- .../test/dataframe_definepersample.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tree/dataframe/test/dataframe_definepersample.cxx b/tree/dataframe/test/dataframe_definepersample.cxx index f731c2bd629ce..32a4c9076382e 100644 --- a/tree/dataframe/test/dataframe_definepersample.cxx +++ b/tree/dataframe/test/dataframe_definepersample.cxx @@ -157,6 +157,24 @@ TEST(DefinePerSampleMore, GetDefinedColumnNames) EXPECT_EQ(df.GetDefinedColumnNames(), std::vector{"x"}); } +// Regression test for https://github.com/root-project/root/issues/12043 +TEST(DefinePerSample, TwoExecutions) +{ + bool flag = false; + auto df = ROOT::RDataFrame(1).DefinePerSample("x", [&flag](unsigned int, const ROOT::RDF::RSampleInfo &) { + flag = true; + return 0; + }); + // Trigger the first execution of the event loop, the flag should be true. + df.Count().GetValue(); + EXPECT_TRUE(flag); + // Reset the flag and trigger again, flag should be again set to true after + // the end of the second event loop. + flag = false; + df.Count().GetValue(); + EXPECT_TRUE(flag); +} + /* TODO // Not supported yet TEST(DefinePerSample, DataSource)