Skip to content

Commit

Permalink
test standalone glob utility
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Feb 5, 2025
1 parent add1917 commit 79a4876
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/root_io/read_glob.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "podio/Reader.h"
#include "podio/utilities/Glob.h"
#if PODIO_ENABLE_DATASOURCE
#include "podio/DataSource.h"
#endif
Expand All @@ -11,11 +12,29 @@
int main() {
const auto pattern = "example_frame_?.root";
const auto expected_events = 20;
const auto reader = podio::makeReader(pattern);
reader.getEvents();
ASSERT((reader.getEntries(podio::Category::Event) == expected_events), "Reader read invalid number of events");
// standalone globbing

ASSERT(podio::utils::is_glob_pattern(pattern), "Failed to recognize glob pattern");
auto files = podio::utils::expand_glob(pattern);
ASSERT(files.size() == 2, "Glob expanded to a wrong number of files");
ASSERT(files[0] == "example_frame_0.root", "Glob expanded to an unexpected file");
ASSERT(files[1] == "example_frame_1.root", "Glob expanded to an unexpected file");
{
// externally resolved glob
const auto reader = podio::makeReader(files);
ASSERT((reader.getEvents() == expected_events), "Reader read invalid number of events");
#if PODIO_ENABLE_DATASOURCE
auto rdf = podio::CreateDataFrame(pattern);
ASSERT(rdf.Count().GetValue() == expected_events, "DataSource read invalid number of events");
auto rdf = podio::CreateDataFrame(files);
ASSERT(rdf.Count().GetValue() == expected_events, "DataSource read invalid number of events");
#endif // PODIO_ENABLE_DATASOURCE
}
{
// implicit globbing
const auto reader = podio::makeReader(pattern);
ASSERT((reader.getEvents() == expected_events), "Reader read invalid number of events");
#if PODIO_ENABLE_DATASOURCE
auto rdf = podio::CreateDataFrame(pattern);
ASSERT(rdf.Count().GetValue() == expected_events, "DataSource read invalid number of events");
#endif // PODIO_ENABLE_DATASOURCE
}
}

0 comments on commit 79a4876

Please # to comment.