From 1f98dbf5ec3bc80473afd45681891f9ccdd06c14 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Mon, 5 Dec 2022 18:51:39 +0100 Subject: [PATCH] Make association read tests version dependent --- .../templates/AssociationsSIOBlock.cc.jinja2 | 3 ++- tests/read_test.h | 26 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/python/templates/AssociationsSIOBlock.cc.jinja2 b/python/templates/AssociationsSIOBlock.cc.jinja2 index 8a590de7f..024befdfd 100644 --- a/python/templates/AssociationsSIOBlock.cc.jinja2 +++ b/python/templates/AssociationsSIOBlock.cc.jinja2 @@ -1,5 +1,6 @@ // AUTOMATICALLY GENERATED FILE - DO NOT EDIT #include "podio/AssociationCollection.h" +#include "podio/detail/AssociationSIOBlock.h" // Datamodel includes {% for include in includes %} @@ -7,5 +8,5 @@ {% endfor %} {% for (from_t, to_t) in combinations %} -static podio::AssociationCollection<{{from_t.full_type}}, {{to_t.full_type}}> podio__association_dummy__{{ package_name }}__{{ loop.index0 }}{}; +static podio::AssociationSIOBlock<{{from_t.full_type}}, {{to_t.full_type}}> podio__association_dummy__{{ package_name }}__sio_block__{{ loop.index0 }}{}; {% endfor %} diff --git a/tests/read_test.h b/tests/read_test.h index ea317c9f2..9c32527ef 100644 --- a/tests/read_test.h +++ b/tests/read_test.h @@ -459,18 +459,20 @@ void processEvent(StoreT& store, int eventNum, podio::version::Version fileVersi } // ======================= Associations ========================== - auto& associations = store.template get("associations"); - if (associations.size() != nmspaces.size()) { - throw std::runtime_error("AssociationsCollection does not have the expected size"); - } - const auto nNameSpc = nmspaces.size(); - int assocIndex = 0; - for (auto assoc : associations) { - if (!((assoc.getWeight() == 0.5 * assocIndex) && (assoc.getFrom() == mcps[assocIndex]) && - (assoc.getTo() == nmspaces[nNameSpc - 1 - assocIndex]))) { - throw std::runtime_error("Association does not have expected content"); - } - assocIndex++; + if (fileVersion >= podio::version::Version{0, 16, 1}) { + auto& associations = store.template get("associations"); + if (associations.size() != nmspaces.size()) { + throw std::runtime_error("AssociationsCollection does not have the expected size"); + } + const auto nNameSpc = nmspaces.size(); + int assocIndex = 0; + for (auto assoc : associations) { + if (!((assoc.getWeight() == 0.5 * assocIndex) && (assoc.getFrom() == mcps[assocIndex]) && + (assoc.getTo() == nmspaces[nNameSpc - 1 - assocIndex]))) { + throw std::runtime_error("Association does not have expected content"); + } + assocIndex++; + } } }