Skip to content

Commit

Permalink
Add a test case show-casing the failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jul 25, 2023
1 parent f16a2d9 commit 888b698
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
36 changes: 36 additions & 0 deletions tests/read_and_write_frame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef PODIO_TESTS_READ_AND_WRITE_FRAME_H // NOLINT(llvm-header-guard): folder structure not suitable
#define PODIO_TESTS_READ_AND_WRITE_FRAME_H // NOLINT(llvm-header-guard): folder structure not suitable

#include "read_frame.h"

#include <string>

template <typename ReaderT, typename WriterT>
int rewrite_frames(const std::string& inputFile, const std::string& newOutput) {
auto reader = ReaderT();
reader.openFile(inputFile);

auto writer = WriterT(newOutput);

const auto frame = podio::Frame(reader.readEntry(podio::Category::Event, 0));
writer.writeFrame(frame, podio::Category::Event);

const auto otherFrame = podio::Frame(reader.readEntry("other_events", 0));
writer.writeFrame(otherFrame, "other_events");

return 0;
}

template <typename ReaderT>
int read_rewritten_frames(const std::string& inputName) {
auto reader = ReaderT();
reader.openFile(inputName);

const auto frame = podio::Frame(reader.readEntry(podio::Category::Event, 0));

processEvent(frame, 0, reader.currentFileVersion());

return 0;
}

#endif // PODIO_TESTS_READ_AND_WRITE_FRAME_H
13 changes: 11 additions & 2 deletions tests/root_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(root_dependent_tests
read_frame_legacy_root.cpp
read_frame_root_multiple.cpp
read_python_frame_root.cpp
read_and_write_frame_root.cpp
)
if(ENABLE_RNTUPLE)
set(root_dependent_tests
Expand All @@ -33,8 +34,16 @@ set_property(TEST read-multiple PROPERTY DEPENDS write)
set_property(TEST read_and_write PROPERTY DEPENDS write)
set_property(TEST read_frame_legacy_root PROPERTY DEPENDS write)
set_property(TEST read_timed PROPERTY DEPENDS write_timed)
set_property(TEST read_frame_root PROPERTY DEPENDS write_frame_root)
set_property(TEST read_frame_root_multiple PROPERTY DEPENDS write_frame_root)

set_tests_properties(
read_frame_root
read_frame_root_multiple
read_and_write_frame_root

PROPERTIES
DEPENDS write_frame_root
)

if(ENABLE_RNTUPLE)
set_property(TEST read_rntuple PROPERTY DEPENDS write_rntuple)
endif()
Expand Down
9 changes: 9 additions & 0 deletions tests/root_io/read_and_write_frame_root.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "read_and_write_frame.h"

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

int main() {
return rewrite_frames<podio::ROOTFrameReader, podio::ROOTFrameWriter>("example_frame.root", "rewritten_frame.root") +
read_rewritten_frames<podio::ROOTFrameReader>("rewritten_frame.root");
}

0 comments on commit 888b698

Please sign in to comment.