Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002    \file
0003    Test Module for testProductRegistry
0004 
0005    \author Stefano ARGIRO
0006    \date 19 May 2005
0007 */
0008 
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "DataFormats/Common/interface/Handle.h"
0011 
0012 #include "FWCore/Framework/test/stubs/TestPRegisterModule2.h"
0013 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0014 #include "FWCore/Version/interface/GetReleaseVersion.h"
0015 #include "cppunit/extensions/HelperMacros.h"
0016 #include <cassert>
0017 #include <memory>
0018 #include <string>
0019 
0020 using namespace edm;
0021 
0022 TestPRegisterModule2::TestPRegisterModule2(edm::ParameterSet const&) {
0023   produces<edmtest::DoubleProduct>();
0024   consumes<edmtest::StringProduct>(edm::InputTag{"m2"});
0025 }
0026 
0027 void TestPRegisterModule2::produce(Event& e, EventSetup const&) {
0028   std::vector<edm::StableProvenance const*> plist;
0029   e.getAllStableProvenance(plist);
0030 
0031   std::vector<edm::StableProvenance const*>::const_iterator pd = plist.begin();
0032 
0033   CPPUNIT_ASSERT(0 != plist.size());
0034   CPPUNIT_ASSERT(2 == plist.size());
0035   CPPUNIT_ASSERT(pd != plist.end());
0036   if (pd == plist.end())
0037     return;  // To silence Coverity
0038   edmtest::StringProduct stringprod;
0039   edm::TypeID stringID(stringprod);
0040   CPPUNIT_ASSERT(stringID.friendlyClassName() == (*pd)->friendlyClassName());
0041   CPPUNIT_ASSERT((*pd)->moduleLabel() == "m1");
0042 
0043   ++pd;
0044   CPPUNIT_ASSERT(pd != plist.end());
0045   if (pd == plist.end())
0046     return;  // To silence Coverity
0047 
0048   edmtest::DoubleProduct dprod;
0049   edm::TypeID dID(dprod);
0050   CPPUNIT_ASSERT(dID.friendlyClassName() == (*pd)->friendlyClassName());
0051   CPPUNIT_ASSERT((*pd)->moduleLabel() == "m2");
0052 
0053   Handle<edmtest::StringProduct> stringp;
0054   e.getByLabel("m2", stringp);
0055   CPPUNIT_ASSERT(stringp->name_ == "m1");
0056 
0057   e.put(std::make_unique<edmtest::DoubleProduct>());
0058 }