Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:00

0001 /*
0002  */
0003 
0004 #include <algorithm>
0005 #include <iostream>
0006 #include <limits>
0007 #include <string>
0008 
0009 #include <cppunit/extensions/HelperMacros.h>
0010 
0011 #include "FWCore/ParameterSet/interface/IncludeFileFinder.h"
0012 
0013 #include "FWCore/PluginManager/interface/PluginManager.h"
0014 #include "FWCore/PluginManager/interface/standard.h"
0015 
0016 using edm::pset::IncludeFileFinder;
0017 using std::pair;
0018 using std::string;
0019 using std::vector;
0020 
0021 class IncludeFileFinderTest : public CppUnit::TestFixture {
0022   CPPUNIT_TEST_SUITE(IncludeFileFinderTest);
0023   CPPUNIT_TEST(strippingTest);
0024   CPPUNIT_TEST(twoWordsTest);
0025   CPPUNIT_TEST(ultimateTest);
0026   CPPUNIT_TEST_SUITE_END();
0027 
0028 public:
0029   void setUp() {
0030     if (not edmplugin::PluginManager::isAvailable()) {
0031       edmplugin::PluginManager::configure(edmplugin::standard::config());
0032     }
0033   }
0034   void tearDown() {}
0035 
0036   void strippingTest();
0037   void stripTrailerTest();
0038   void twoWordsTest();
0039   void ultimateTest();
0040 
0041 private:
0042 };
0043 
0044 ///registration of the test so that the runner can find it
0045 CPPUNIT_TEST_SUITE_REGISTRATION(IncludeFileFinderTest);
0046 
0047 void IncludeFileFinderTest::strippingTest() {
0048   string original = "libSimCalorimetryCaloSimAlgosPlugins.so";
0049 
0050   string result = IncludeFileFinder::stripHeader(original);
0051   CPPUNIT_ASSERT(result == "SimCalorimetryCaloSimAlgosPlugins.so");
0052 
0053   string result2 = IncludeFileFinder::stripTrailer(result);
0054   CPPUNIT_ASSERT(result2 == "SimCalorimetryCaloSimAlgos");
0055 }
0056 
0057 void IncludeFileFinderTest::twoWordsTest() {
0058   string original = "SimCalorimetryCaloSimAlgos";
0059   vector<pair<string, string> > twoWords = IncludeFileFinder::twoWordsFrom(original);
0060 
0061   CPPUNIT_ASSERT(twoWords.size() == 4);
0062   CPPUNIT_ASSERT(twoWords[0].first == "Sim");
0063   CPPUNIT_ASSERT(twoWords[0].second == "CalorimetryCaloSimAlgos");
0064   CPPUNIT_ASSERT(twoWords[1].first == "SimCalorimetry");
0065   CPPUNIT_ASSERT(twoWords[1].second == "CaloSimAlgos");
0066   CPPUNIT_ASSERT(twoWords[2].first == "SimCalorimetryCalo");
0067   CPPUNIT_ASSERT(twoWords[2].second == "SimAlgos");
0068   CPPUNIT_ASSERT(twoWords[3].first == "SimCalorimetryCaloSim");
0069   CPPUNIT_ASSERT(twoWords[3].second == "Algos");
0070 }
0071 
0072 void IncludeFileFinderTest::ultimateTest() {
0073   string moduleClass = "CSCDigiProducer";
0074   IncludeFileFinder finder;
0075   //  string library = finder.libraryOf(moduleClass);
0076   //  CPPUNIT_ASSERT (library == "libSimMuonCSCDigitizer.so");
0077 
0078   string moduleLabel = "muoncscdigi";
0079   //  edm::FileInPath file = finder.find(moduleClass, moduleLabel);
0080   // will throw if can't find
0081 }