Skip to content

Commit

Permalink
Add test case for checking whether reading limited set works
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Oct 11, 2023
1 parent 1ab6723 commit 58f9802
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/root_io/read_frame_root.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
#include "read_frame.h"
#include "read_frame_auxiliary.h"

#include "podio/Frame.h"
#include "podio/ROOTFrameReader.h"

#include <iostream>
#include <set>
#include <string>
#include <vector>

int test_read_frame_limited(const std::string& inputFile) {
auto reader = podio::ROOTFrameReader();
reader.openFile(inputFile);
const std::vector<std::string> collsToRead = {"mcparticles", "clusters"};

const auto event = podio::Frame(reader.readNextEntry("events", collsToRead));

const auto& availColls = event.getAvailableCollections();

const bool validColls =
std::set(availColls.begin(), availColls.end()) != std::set(collsToRead.begin(), collsToRead.end());

if (validColls) {
std::cerr << "The available collections are not as expected" << std::endl;
return 1;
}

const auto& mcps = event.get<ExampleMCCollection>("mcparticles");
const auto& clusters = event.get<ExampleClusterCollection>("clusters");

if (event.get("hits")) {
std::cerr << "Collection 'hits' is available, but should not be" << std::endl;
return 1;
}

const auto clu0 = clusters[0];
const auto hits = clu0.Hits();
if (hits.size() != 1 || hits[0].isAvailable()) {
std::cerr << "Hit in clusters are available but shouldn't be" << std::endl;
return 1;
}

return 0;
}

int main(int argc, char* argv[]) {
std::string inputFile = "example_frame.root";
Expand All @@ -15,5 +53,5 @@ int main(int argc, char* argv[]) {
}

return read_frames<podio::ROOTFrameReader>(inputFile, assertBuildVersion) +
test_frame_aux_info<podio::ROOTFrameReader>(inputFile);
test_frame_aux_info<podio::ROOTFrameReader>(inputFile) + test_read_frame_limited(inputFile);
}

0 comments on commit 58f9802

Please sign in to comment.