14 #include "cetlib_except/exception.h" 32 assert(v.
vals().size() > 0);
60 void test_getViewReturnFalse(
art::Event const&
e)
const;
61 void test_getViewThrowing(
art::Event const&
e)
const;
65 static constexpr std::size_t
71 template <
typename DATA_TYPE>
74 std::size_t nElements = expectedSize())
const;
83 consumesView<Simple>(tagWithInstance_)};
85 consumesView<Simple>(tagForCurrentProcess_)};
87 consumesView<SimpleDerived>(tagWithInstance_)};
89 consumesView<SimpleDerived>(tagForCurrentProcess_)};
129 for (std::size_t
k = 0;
k != sz; ++
k) {
130 assert((
unsigned)ptrs[
k]->
key == sz -
k + event_num);
131 double expect = 1.5 *
k + 100.0;
132 assert(ptrs[
k]->
value == expect);
133 assert(ptrs[
k]->
dummy() == 16.25);
137 template <
typename T>
142 std::size_t
const nvalues)
144 auto const event_num = e.
id().
event();
145 std::vector<T const*> ptrs;
146 auto sz = e.
getView(token, ptrs);
147 assert(sz == nvalues);
150 sz = e.
getView(tokenForCurrentProcess, ptrs);
151 assert(sz == nvalues);
155 assert(v.
vals().size() == nvalues);
158 assert(e.
getView(tokenForCurrentProcess, v2));
159 assert(v2.vals().size() == nvalues);
163 v.
vals().front() = 0;
166 for (std::size_t
i = 0, sz = pvec.
size();
i != sz; ++
i) {
167 assert(*pvec[
i] == *v.
vals()[
i + 1]);
182 std::vector<int const*> ints;
184 assert(e.
getView(
"nothing with this illegal label", ints) ==
false);
187 std::cerr << e.what() <<
'\n';
188 assert(
"Unexpected exception thrown" == 0);
191 assert(
"Unexpected exception thrown" == 0);
200 std::vector<dummy const*> dummies;
203 assert(
"Failed to throw required exception" == 0);
209 assert(
"Wrong exception thrown" == 0);
216 auto const event_num = e.
id().
event();
222 auto const sz =
d.size();
226 <<
" but the obtained size is " << sz <<
'\n';
240 auto il = {*(
i++), *
i};
241 base_product_t
s{il};
262 p = {s.front(), s.back()};
268 s.assign(1,
d.front());
271 p.assign(1,
s.front());
277 s.assign(
d.cbegin(),
d.cend());
280 p.assign(
s.cbegin(),
s.cend());
287 s.assign({*(
i++), *
i});
290 p.assign({
s.front(),
s.back()});
296 s.push_back(
d.front());
299 p.push_back(s.front());
304 base_product_t
s({
d[1]});
305 s.insert(
s.begin(),
d.front());
307 base_product_t
p({
s.back()});
308 p.insert(
p.begin(),
s.front());
314 s.insert(s.begin(),
d.cbegin(),
d.cend());
317 p.insert(p.begin(), s.cbegin(), s.cend());
323 s.erase(
s.end() - 1);
325 s.erase(
s.begin() + 1,
s.end());
330 template <
typename DATA_TYPE>
334 std::size_t
const nElements)
const 336 auto const sz(v.
size());
337 if (sz != nElements) {
339 <<
"Expected size " << nElements <<
" but got " << sz <<
".\n";
342 auto const e = v.
cbegin() + nElements;
343 for (
auto i =
b;
i !=
e; ++
i) {
344 std::size_t
const k =
i -
b;
345 if (static_cast<std::size_t>((*i)->key) !=
expectedSize() - k + event_num) {
347 <<
"At position " << k <<
" expected key " 348 <<
expectedSize() - k + event_num <<
" but obtained " << (*i)->key
352 if (k == 0 && sz > 1) {
353 assert(*
i != *(
i + 1));
354 assert(*(
i) < *(
i + 1));
357 double const expect{1.5 * k + 100.0};
358 if ((*i)->value != expect) {
360 <<
"At position " << k <<
" expected value " << expect
361 <<
" but obtained " << (*i)->value <<
".\n";
363 if ((*i)->dummy() != 16.25) {
365 <<
"At position " << k <<
" expected dummy value " << 16.25
366 <<
" but obtained " << (*i)->dummy() <<
".\n";
def analyze(root, level, gtrees, gbranches, doprint)
void test_view(art::Event const &e, art::ViewToken< T > const &token, art::ViewToken< T > const &tokenForCurrentProcess, std::size_t const nvalues)
art::ViewToken< SimpleDerived > const simpleDerivedToken_
void test_PtrVector(art::Event const &e) const
void analyze(art::Event const &e) override
art::InputTag const tagWithInstance_
std::size_t const nvalues_
void check_for_conversion(art::View< T > const &v)
void fill(PtrVector< T > &pv) const
art::ViewToken< SimpleDerived > const simpleDerivedCurrentToken_
std::vector< SimpleDerived > SimpleDerivedProduct
void verify_elements(std::vector< T > const &ptrs, std::size_t sz, art::EventNumber_t event_num, std::size_t)
#define DEFINE_ART_MODULE(klass)
art::ViewToken< Simple > const simpleCurrentToken_
SimpleDerivedAnalyzer(Parameters const &p)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
void test_getViewThrowing(art::Event const &e) const
const_iterator cbegin() const
static constexpr std::size_t expectedSize()
art::ProductToken< art::PtrVector< SimpleDerived > > const ptrVectorToken_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
art::InputTag const tagForCurrentProcess_
art::ViewToken< dummy > const dummyToken_
IDNumber_t< Level::Event > EventNumber_t
cet::LibraryManager dummy("noplugin")
art::ViewToken< Simple > const simpleToken_
EventNumber_t event() const
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
cet::coded_exception< error, detail::translate > exception
void test_getViewReturnFalse(art::Event const &e) const
void test_getView(art::Event const &e) const