13 #include "canvas/Persistency/Provenance/ProductID.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 #include "canvas/Persistency/Common/Assns.h"
18 #define BOOST_TEST_MODULE ( PointIsolationAlg_test )
19 #include "boost/test/unit_test.hpp"
29 #include "TInterpreter.h"
30 #include "TClassEdit.h"
40 TInterpreter* interpreter = gROOT->GetInterpreter();
44 char* classNameC = TClassEdit::DemangleTypeIdName(
typeid(T), err);
47 std::string normalizedClassName;
48 TClassEdit::GetNormalizedName(normalizedClassName, classNameC);
51 std::free(classNameC);
54 return interpreter->GenerateTClass(normalizedClassName.c_str(), kTRUE, kTRUE);
66 using MyAssns_t = art::Assns<TypeA, TypeB>;
71 QuickGenerateTClass<MyAssns_t>();
73 using Index_t = art::Ptr<TypeA>::key_type;
76 std::array<std::pair<Index_t, std::vector<Index_t>>, 3U> expected;
77 expected[0] = { 0, { 0, 3, 6 } };
78 expected[1] = { 1, { 2, 4, 6 } };
79 expected[2] = { 3, { 8, 10, 12, 13 } };
80 art::ProductID aPID{ 5 }, bPID{ 12 };
84 for (
auto const& pair: expected) {
85 auto const& aIndex = pair.first;
86 for (
auto const& bIndex: pair.second) {
87 assns.addSingle({ aPID, aIndex,
nullptr }, { bPID, bIndex,
nullptr });
91 std::vector<std::vector<Index_t>> results;
93 std::cout <<
"Association group #" << results.size() <<
":" << std::endl;
94 results.emplace_back();
95 std::vector<Index_t>& myBs = results.back();
96 for(art::Ptr<TypeB>
const& B: Bs) {
98 myBs.push_back(B.key());
103 std::cout <<
"Starting check..." << std::endl;
104 BOOST_TEST(results.size() == expected.size());
105 for (
size_t i = 0; i < results.size(); ++i) {
106 auto const& Bs = results[i];
107 auto const& expectedBs = expected[i].second;
108 BOOST_TEST_MESSAGE(
" element #" << i <<
", A=" << expected[i].
first);
109 BOOST_TEST(Bs.size() == expectedBs.size());
110 for (
size_t j = 0; j < expectedBs.size(); ++j) {
111 BOOST_TEST_MESSAGE(
" assn #" << j);
112 BOOST_TEST(Bs[j] == expectedBs[j]);
EResult err(const char *call)
unsigned int Index_t
Type to denote the index of the flag.
auto associated_groups(A const &assns)
Helper functions to access associations in order.
void AssociatedGroupsTest()
Helper functions to access associations in order.
BEGIN_PROLOG could also be cout
TClass * QuickGenerateTClass()