Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-24 04:44:54

0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002 #include "FWCore/TestProcessor/interface/TestSourceProcessor.h"
0003 
0004 #include <cppunit/extensions/HelperMacros.h>
0005 
0006 class testTestSourceProcessor : public CppUnit::TestFixture {
0007   CPPUNIT_TEST_SUITE(testTestSourceProcessor);
0008   CPPUNIT_TEST(simpleTest);
0009 
0010   CPPUNIT_TEST_SUITE_END();
0011 
0012 public:
0013   void setUp() {}
0014   void tearDown() {}
0015   void simpleTest();
0016 
0017 private:
0018 };
0019 
0020 ///registration of the test so that the runner can find it
0021 CPPUNIT_TEST_SUITE_REGISTRATION(testTestSourceProcessor);
0022 
0023 void testTestSourceProcessor::simpleTest() {
0024   char const* kTest =
0025       "from FWCore.TestProcessor.TestSourceProcess import *\n"
0026       "process = TestSourceProcess()\n"
0027       "process.source = cms.Source('TestSource',"
0028       "transitions = cms.untracked.VPSet(\n"
0029       "cms.PSet(type = cms.untracked.string('IsFile'),\n"
0030       "         id = cms.untracked.EventID(0,0,0)),\n"
0031       "cms.PSet(type = cms.untracked.string('IsRun'),\n"
0032       "         id = cms.untracked.EventID(1,0,0)),\n"
0033       "cms.PSet(type = cms.untracked.string('IsLumi'),\n"
0034       "         id = cms.untracked.EventID(1,1,0)),\n"
0035       "cms.PSet(type = cms.untracked.string('IsEvent'),\n"
0036       "         id = cms.untracked.EventID(1,1,1)),\n"
0037       "cms.PSet(type = cms.untracked.string('IsEvent'),\n"
0038       "         id = cms.untracked.EventID(1,1,2)),\n"
0039       "cms.PSet(type = cms.untracked.string('IsEvent'),\n"
0040       "         id = cms.untracked.EventID(1,1,3)),\n"
0041       "cms.PSet(type = cms.untracked.string('IsEvent'),\n"
0042       "         id = cms.untracked.EventID(1,1,4)),\n"
0043       "cms.PSet(type = cms.untracked.string('IsEvent'),\n"
0044       "         id = cms.untracked.EventID(1,1,5)),\n"
0045       "cms.PSet(type = cms.untracked.string('IsStop'),\n"
0046       "         id = cms.untracked.EventID(0,0,0))\n"
0047       "))\n";
0048   edm::test::TestSourceProcessor tester(kTest);
0049 
0050   {
0051     auto n = tester.findNextTransition();
0052     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsFile);
0053     auto f = tester.openFile();
0054     CPPUNIT_ASSERT(bool(f));
0055   }
0056   {
0057     auto n = tester.findNextTransition();
0058     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsRun);
0059     auto r = tester.readRun();
0060     CPPUNIT_ASSERT(r.run() == 1);
0061   }
0062   {
0063     auto n = tester.findNextTransition();
0064     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsLumi);
0065     auto r = tester.readLuminosityBlock();
0066     CPPUNIT_ASSERT(r.run() == 1);
0067     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0068   }
0069   {
0070     auto n = tester.findNextTransition();
0071     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsEvent);
0072     auto r = tester.readEvent();
0073     CPPUNIT_ASSERT(r.run() == 1);
0074     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0075     CPPUNIT_ASSERT(r.event() == 1);
0076   }
0077   {
0078     auto n = tester.findNextTransition();
0079     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsEvent);
0080     auto r = tester.readEvent();
0081     CPPUNIT_ASSERT(r.run() == 1);
0082     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0083     CPPUNIT_ASSERT(r.event() == 2);
0084   }
0085   {
0086     auto n = tester.findNextTransition();
0087     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsEvent);
0088     auto r = tester.readEvent();
0089     CPPUNIT_ASSERT(r.run() == 1);
0090     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0091     CPPUNIT_ASSERT(r.event() == 3);
0092   }
0093   {
0094     auto n = tester.findNextTransition();
0095     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsEvent);
0096     auto r = tester.readEvent();
0097     CPPUNIT_ASSERT(r.run() == 1);
0098     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0099     CPPUNIT_ASSERT(r.event() == 4);
0100   }
0101   {
0102     auto n = tester.findNextTransition();
0103     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsEvent);
0104     auto r = tester.readEvent();
0105     CPPUNIT_ASSERT(r.run() == 1);
0106     CPPUNIT_ASSERT(r.luminosityBlock() == 1);
0107     CPPUNIT_ASSERT(r.event() == 5);
0108   }
0109   {
0110     auto n = tester.findNextTransition();
0111     CPPUNIT_ASSERT(n == edm::InputSource::ItemType::IsStop);
0112   }
0113 }