-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests for the EmptyEventCreator source
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef TestEmptyEventCreator_h | ||
#define TestEmptyEventCreator_h 1 | ||
|
||
#include "marlin/Processor.h" | ||
|
||
#include "lcio.h" | ||
|
||
/** Test processor to check that the EmptyEventCreator data source produces the | ||
* expected empty events | ||
*/ | ||
class TestEmptyEventCreator : public marlin::Processor { | ||
|
||
public: | ||
TestEmptyEventCreator *newProcessor() override { | ||
return new TestEmptyEventCreator; | ||
} | ||
|
||
TestEmptyEventCreator(); | ||
|
||
void processRunHeader(lcio::LCRunHeader *run) override; | ||
|
||
void processEvent(lcio::LCEvent *evt) override; | ||
|
||
private: | ||
int m_expectedEvt{0}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "TestEmptyEventCreator.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
TestEmptyEventCreator aTestEmptyEventCreator; | ||
|
||
TestEmptyEventCreator::TestEmptyEventCreator() | ||
: marlin::Processor("TestEmptyEventCreator") { | ||
_description = "Processor to test whether the EmptyEventCreator data source " | ||
"works as expected"; | ||
} | ||
|
||
void TestEmptyEventCreator::processRunHeader(lcio::LCRunHeader *run) { | ||
if (run->getRunNumber() != 0) { | ||
throw lcio::Exception("Run number from EmptyEventCreator is not 0 (" + | ||
std::to_string(run->getRunNumber()) + ")"); | ||
} | ||
} | ||
|
||
void TestEmptyEventCreator::processEvent(lcio::LCEvent *evt) { | ||
if (evt->getEventNumber() != m_expectedEvt) { | ||
throw lcio::Exception( | ||
"Event number from EmptyEventCreator is not as expected (expected: " + | ||
std::to_string(m_expectedEvt) + | ||
", actual: " + std::to_string(evt->getEventNumber()) + ")"); | ||
} | ||
|
||
if (!evt->getCollectionNames()->empty()) { | ||
throw lcio::Exception( | ||
"EmptyEventCreator should create empty events, but LCEvent contains " + | ||
std::to_string(evt->getCollectionNames()->size()) + " collections"); | ||
} | ||
|
||
const auto ¶ms = evt->getParameters(); | ||
|
||
std::vector<std::string> keys; | ||
params.getIntKeys(keys); | ||
if (!keys.empty()) { | ||
throw lcio::Exception( | ||
"EmptyEventCreator should create empty events, but has int parameters"); | ||
} | ||
keys.clear(); | ||
|
||
params.getFloatKeys(keys); | ||
if (!keys.empty()) { | ||
throw lcio::Exception("EmptyEventCreator should create empty events, but " | ||
"has float parameters"); | ||
} | ||
keys.clear(); | ||
|
||
params.getStringKeys(keys); | ||
if (!keys.empty()) { | ||
throw lcio::Exception("EmptyEventCreator should create empty events, but " | ||
"has string parameters"); | ||
} | ||
|
||
m_expectedEvt++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<marlin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ilcsoft.desy.de/marlin/marlin.xsd"> | ||
|
||
<execute> | ||
<processor name="EmptyEventCreator"/> | ||
<processor name="MyTestEmptyEventCreator"/> | ||
</execute> | ||
|
||
<global> | ||
<parameter name="MaxRecordNumber" value="10"/> | ||
</global> | ||
|
||
<processor name="EmptyEventCreator" type="EmptyEventCreator"/> | ||
|
||
<processor name="MyTestEmptyEventCreator" type="TestEmptyEventCreator"> | ||
<!--Processor to test whether the EmptyEventCreator data source works as expected--> | ||
<!--verbosity level of this processor ("DEBUG0-4,MESSAGE0-4,WARNING0-4,ERROR0-4,SILENT")--> | ||
<!--parameter name="Verbosity" type="string">DEBUG </parameter--> | ||
</processor> | ||
|
||
</marlin> |