Skip to content

Commit

Permalink
Make association read tests version dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 5, 2022
1 parent 03b3c12 commit 1f98dbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion python/templates/AssociationsSIOBlock.cc.jinja2
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
#include "podio/AssociationCollection.h"
#include "podio/detail/AssociationSIOBlock.h"

// Datamodel includes
{% for include in includes %}
{{ include }}
{% 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 %}
26 changes: 14 additions & 12 deletions tests/read_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,20 @@ void processEvent(StoreT& store, int eventNum, podio::version::Version fileVersi
}

// ======================= Associations ==========================
auto& associations = store.template get<TestAssocCollection>("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<TestAssocCollection>("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++;
}
}
}

Expand Down

0 comments on commit 1f98dbf

Please sign in to comment.