Skip to content

Commit

Permalink
Add content checks for roundtripped files with dropped collections
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jan 16, 2025
1 parent 2fb411a commit a961357
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/selected_colls_roundtrip.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "read_test.h"

#include <podio/Frame.h>

#include <algorithm>
Expand All @@ -24,10 +26,13 @@
/// be called by backend specific tests

/// The collection names that will be written into the new file
const std::vector<std::string> collectionSelection = {"mcparticles", "links", "userInts", "hits"};
const std::vector<std::string> collectionSelection = {"mcparticles", "links", "userInts", "hits", "clusters"};

/// The collections to select in the second round
const std::vector<std::string> roundTripSelection = {"hits", "userInts"};
const std::vector<std::string> roundTripSelection = {"hits", "userInts", "mcparticles"};

/// Collections that were available originally and shouldn't be any longer
const std::vector<std::string> droppedCollections = {"moreMCs", "userDoubles", "info", "refs", "hitRefs"};

/// Write a new file containing only a few selected collections and only one
/// event
Expand Down Expand Up @@ -71,6 +76,21 @@ int readSelectedFileFull(const std::string& filename) {
return 1;
}

for (const auto& name : droppedCollections) {
if (event.get(name)) {
std::cerr << "The frame contained a dropped collection: " << name << std::endl;
return 1;
}
}

checkMCParticleCollection(event, reader.currentFileVersion());
checkHitCollection(event, 0);
const auto& hits = event.get<ExampleHitCollection>("hits");
checkClusterCollection(event, hits);
const auto& clusters = event.get<ExampleClusterCollection>("clusters");
checkIntUserDataCollection(event, 0);
checkLinkCollection(event, hits, clusters);

return 0;
}

Expand All @@ -90,6 +110,10 @@ int readSelectedFilePartial(const std::string& filename) {
return 1;
}

checkMCParticleCollection(event, reader.currentFileVersion());
checkHitCollection(event, 0);
checkIntUserDataCollection(event, 0);

return 0;
}

Expand Down

0 comments on commit a961357

Please sign in to comment.