14 #include "canvas/Persistency/Provenance/ProductID.h"
15 #include "canvas/Persistency/Common/Ptr.h"
16 #include "canvas/Persistency/Common/Assns.h"
19 #define BOOST_TEST_MODULE ( PointIsolationAlg_test )
20 #include "boost/test/unit_test.hpp"
30 #include "TInterpreter.h"
31 #include "TClassEdit.h"
41 TInterpreter* interpreter = gROOT->GetInterpreter();
45 char* classNameC = TClassEdit::DemangleTypeIdName(
typeid(T), err);
48 std::string normalizedClassName;
49 TClassEdit::GetNormalizedName(normalizedClassName, classNameC);
52 std::free(classNameC);
55 return interpreter->GenerateTClass(normalizedClassName.c_str(), kTRUE, kTRUE);
67 using MyAssns_t = art::Assns<TypeA, TypeB>;
72 QuickGenerateTClass<MyAssns_t>();
74 using Index_t = art::Ptr<TypeA>::key_type;
77 std::array<std::pair<Index_t, std::vector<Index_t>>, 3U> expected;
78 expected[0] = { 0, { 0, 3, 6 } };
79 expected[1] = { 1, { 2, 4, 6 } };
80 expected[2] = { 3, { 8, 10, 12, 13 } };
81 art::ProductID aPID{ 5 }, bPID{ 12 };
85 for (
auto const& pair: expected) {
86 auto const& aIndex = pair.first;
87 for (
auto const& bIndex: pair.second) {
88 assns.addSingle({ aPID, aIndex,
nullptr }, { bPID, bIndex,
nullptr });
92 std::vector<std::pair<Index_t, std::vector<Index_t>>> results;
94 std::cout <<
"Association group #" << results.size() <<
":" << std::endl;
95 std::vector<Index_t> myBs;
96 myBs.reserve(Bs.size());
97 for(art::Ptr<TypeB>
const& B: Bs) {
99 myBs.push_back(B.key());
101 results.emplace_back(
A.key(), std::move(myBs));
105 std::cout <<
"Starting check..." << std::endl;
106 BOOST_TEST(results.size() == expected.size());
107 for (
auto const& [ i, result, expected ]:
util::enumerate(results, expected))
109 auto const& [
A, Bs ] = result;
110 auto const& [ expectedA, expectedBs ] = expected;
111 BOOST_TEST_MESSAGE(
" element #" << i <<
", A=" << expectedA);
112 BOOST_TEST(
A == expectedA);
113 BOOST_CHECK_EQUAL_COLLECTIONS
114 (Bs.cbegin(), Bs.cend(), expectedBs.cbegin(), expectedBs.cend());
void associated_groups_with_left_test()
auto associated_groups_with_left(A const &assns)
Helper functions to access associations in order, also with key.
Definition of util::enumerate().
EResult err(const char *call)
unsigned int Index_t
Type to denote the index of the flag.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Helper functions to access associations in order.
BEGIN_PROLOG could also be cout
TClass * QuickGenerateTClass()