Unit test for util::associated_groups()
.
More...
#include "lardata/Utilities/ForEachAssociatedGroup.h"
#include "canvas/Persistency/Provenance/ProductID.h"
#include "canvas/Persistency/Common/Ptr.h"
#include "canvas/Persistency/Common/Assns.h"
#include "boost/test/unit_test.hpp"
#include <array>
#include <iostream>
#include "TROOT.h"
#include "TInterpreter.h"
#include "TClassEdit.h"
#include <string>
#include <typeinfo>
Go to the source code of this file.
#define BOOST_TEST_MODULE ( PointIsolationAlg_test ) |
void AssociatedGroupsTest |
( |
| ) |
|
Definition at line 60 of file associated_groups_test.cc.
71 QuickGenerateTClass<MyAssns_t>();
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 } };
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();
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]);
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.
QTextStream & endl(QTextStream &s)
BOOST_AUTO_TEST_CASE |
( |
AssociatedGroupsTestCase |
| ) |
|
template<typename T >
TClass* QuickGenerateTClass |
( |
| ) |
|
Definition at line 37 of file associated_groups_test.cc.
40 TInterpreter* interpreter = gROOT->GetInterpreter();
44 char* classNameC = TClassEdit::DemangleTypeIdName(
typeid(
T), err);
48 TClassEdit::GetNormalizedName(normalizedClassName, classNameC);
51 std::free(classNameC);
54 return interpreter->GenerateTClass(normalizedClassName.c_str(), kTRUE, kTRUE);
void err(const char *fmt,...)