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 = "[Prescaler]";
0007 TEST_CASE("Check parameters of Prescaler", s_tag) {
0008   const std::string baseConfig{
0009       R"_(from FWCore.TestProcessor.TestProcess import *
0010 process = TestProcess()
0011 process.prescale = cms.EDFilter('Prescaler',
0012                                  prescaleFactor =cms.int32(3),
0013                                  prescaleOffset = cms.int32(offset))
0014 process.moduleToTest(process.prescale)
0015 )_"};
0016 
0017   SECTION("prescaleFactor sets how many events to fail before success") {
0018     edm::test::TestProcessor::Config config{"offset=1\n" + baseConfig};
0019 
0020     edm::test::TestProcessor tester(config);
0021     REQUIRE(tester.test().modulePassed());
0022     REQUIRE_FALSE(tester.test().modulePassed());
0023     REQUIRE_FALSE(tester.test().modulePassed());
0024     REQUIRE(tester.test().modulePassed());
0025     REQUIRE_FALSE(tester.test().modulePassed());
0026     REQUIRE_FALSE(tester.test().modulePassed());
0027     REQUIRE(tester.test().modulePassed());
0028   }
0029 
0030   SECTION("prescaleOffset sets which event succeeds") {
0031     edm::test::TestProcessor::Config config{"offset=2\n" + baseConfig};
0032 
0033     edm::test::TestProcessor tester(config);
0034     REQUIRE_FALSE(tester.test().modulePassed());
0035     REQUIRE(tester.test().modulePassed());
0036     REQUIRE_FALSE(tester.test().modulePassed());
0037     REQUIRE_FALSE(tester.test().modulePassed());
0038     REQUIRE(tester.test().modulePassed());
0039   }
0040 }
0041 
0042 TEST_CASE("No default parameters of Prescaler", s_tag) {
0043   const std::string config{
0044       R"_(from FWCore.TestProcessor.TestProcess import *
0045 process = TestProcess()
0046 process.prescale = cms.EDFilter('Prescaler')
0047 process.moduleToTest(process.prescale)
0048 )_"};
0049 
0050   REQUIRE_THROWS_AS(edm::test::TestProcessor(config), cms::Exception);
0051 }