Skip to content

Commit df9b28f

Browse files
authored
Merge 977fa0e into sapling-pr-archive-ktf
2 parents 3e12710 + 977fa0e commit df9b28f

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎Framework/Foundation/test/test_StructToTuple.cxx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,32 @@ TEST_CASE("TestStructToTuple")
164164
REQUIRE(t6.size() == 3);
165165
REQUIRE(t6[0] == true);
166166
}
167+
168+
/// Empty base class, mirroring o2::framework::ConfigurableGroup: structs
169+
/// deriving from it must decompose to their own members only, and the empty
170+
/// base must not be counted or bound. Exercised with B=true, as the option
171+
/// group handling in AnalysisManagers.h does.
172+
struct EmptyBase {
173+
};
174+
175+
struct DerivedGroup : EmptyBase {
176+
int a = 3;
177+
int b = 30;
178+
int c = 300;
179+
};
180+
181+
TEST_CASE("EmptyBaseDestructuring")
182+
{
183+
DerivedGroup g;
184+
auto t = o2::framework::homogeneous_apply_refs<true>([](auto i) -> bool { return i > 20; }, g);
185+
REQUIRE(t.size() == 3);
186+
REQUIRE(t[0] == false);
187+
REQUIRE(t[1] == true);
188+
REQUIRE(t[2] == true);
189+
190+
// The binding must reach the derived members, not the base.
191+
o2::framework::homogeneous_apply_refs<true>([](auto& i) { i += 1; return true; }, g);
192+
REQUIRE(g.a == 4);
193+
REQUIRE(g.b == 31);
194+
REQUIRE(g.c == 301);
195+
}

0 commit comments

Comments
 (0)