Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:49

0001 #include "FWCore/TestProcessor/interface/TestProcessor.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 
0004 #include "catch.hpp"
0005 
0006 static constexpr auto s_tag = "[ModuloEventIDFilter]";
0007 
0008 TEST_CASE("Check parameters of ModuloEventIDFilter", s_tag) {
0009   const std::string baseConfig{
0010       R"_(from FWCore.TestProcessor.TestProcess import *
0011 process = TestProcess()
0012 process.toTest = cms.EDFilter('ModuloEventIDFilter',
0013                                  modulo =cms.uint32(3),
0014                                  offset = cms.uint32(offset))
0015 process.moduleToTest(process.toTest)
0016 )_"};
0017 
0018   SECTION("modulo sets how many events to fail before success") {
0019     edm::test::TestProcessor::Config config{"offset=1\n" + baseConfig};
0020 
0021     edm::test::TestProcessor tester(config);
0022     tester.setEventNumber(1);
0023     REQUIRE(tester.test().modulePassed());
0024     REQUIRE_FALSE(tester.test().modulePassed());
0025     REQUIRE_FALSE(tester.test().modulePassed());
0026     REQUIRE(tester.test().modulePassed());
0027     REQUIRE_FALSE(tester.test().modulePassed());
0028     REQUIRE_FALSE(tester.test().modulePassed());
0029     REQUIRE(tester.test().modulePassed());
0030     tester.setEventNumber(10);
0031     REQUIRE(tester.test().modulePassed());
0032     tester.setEventNumber(13);
0033     REQUIRE(tester.test().modulePassed());
0034     tester.setEventNumber(15);
0035     REQUIRE_FALSE(tester.test().modulePassed());
0036   }
0037 
0038   SECTION("offset sets which event succeeds") {
0039     edm::test::TestProcessor::Config config{"offset=2\n" + baseConfig};
0040 
0041     edm::test::TestProcessor tester(config);
0042     tester.setEventNumber(1);
0043     REQUIRE_FALSE(tester.test().modulePassed());
0044     REQUIRE(tester.test().modulePassed());
0045     REQUIRE_FALSE(tester.test().modulePassed());
0046     REQUIRE_FALSE(tester.test().modulePassed());
0047     REQUIRE(tester.test().modulePassed());
0048     tester.setEventNumber(8);
0049     REQUIRE(tester.test().modulePassed());
0050     tester.setEventNumber(11);
0051     REQUIRE(tester.test().modulePassed());
0052     tester.setEventNumber(13);
0053     REQUIRE_FALSE(tester.test().modulePassed());
0054   }
0055 }
0056 
0057 TEST_CASE("No default parameters of ModuloEventIDFilter", s_tag) {
0058   const std::string config{
0059       R"_(from FWCore.TestProcessor.TestProcess import *
0060 process = TestProcess()
0061 process.toTest = cms.EDFilter('ModuloEventIDFilter')
0062 process.moduleToTest(process.toTest)
0063 )_"};
0064 
0065   REQUIRE_THROWS_AS(edm::test::TestProcessor(config), cms::Exception);
0066 }