1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
*/
#include <algorithm>
#include <iostream>
#include <limits>
#include <string>
#include <cppunit/extensions/HelperMacros.h>
#include "FWCore/ParameterSet/interface/IncludeFileFinder.h"
#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"
using edm::pset::IncludeFileFinder;
using std::pair;
using std::string;
using std::vector;
class IncludeFileFinderTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(IncludeFileFinderTest);
CPPUNIT_TEST(strippingTest);
CPPUNIT_TEST(twoWordsTest);
CPPUNIT_TEST(ultimateTest);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
if (not edmplugin::PluginManager::isAvailable()) {
edmplugin::PluginManager::configure(edmplugin::standard::config());
}
}
void tearDown() {}
void strippingTest();
void stripTrailerTest();
void twoWordsTest();
void ultimateTest();
private:
};
///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(IncludeFileFinderTest);
void IncludeFileFinderTest::strippingTest() {
string original = "libSimCalorimetryCaloSimAlgosPlugins.so";
string result = IncludeFileFinder::stripHeader(original);
CPPUNIT_ASSERT(result == "SimCalorimetryCaloSimAlgosPlugins.so");
string result2 = IncludeFileFinder::stripTrailer(result);
CPPUNIT_ASSERT(result2 == "SimCalorimetryCaloSimAlgos");
}
void IncludeFileFinderTest::twoWordsTest() {
string original = "SimCalorimetryCaloSimAlgos";
vector<pair<string, string> > twoWords = IncludeFileFinder::twoWordsFrom(original);
CPPUNIT_ASSERT(twoWords.size() == 4);
CPPUNIT_ASSERT(twoWords[0].first == "Sim");
CPPUNIT_ASSERT(twoWords[0].second == "CalorimetryCaloSimAlgos");
CPPUNIT_ASSERT(twoWords[1].first == "SimCalorimetry");
CPPUNIT_ASSERT(twoWords[1].second == "CaloSimAlgos");
CPPUNIT_ASSERT(twoWords[2].first == "SimCalorimetryCalo");
CPPUNIT_ASSERT(twoWords[2].second == "SimAlgos");
CPPUNIT_ASSERT(twoWords[3].first == "SimCalorimetryCaloSim");
CPPUNIT_ASSERT(twoWords[3].second == "Algos");
}
void IncludeFileFinderTest::ultimateTest() {
string moduleClass = "CSCDigiProducer";
IncludeFileFinder finder;
// string library = finder.libraryOf(moduleClass);
// CPPUNIT_ASSERT (library == "libSimMuonCSCDigitizer.so");
string moduleLabel = "muoncscdigi";
// edm::FileInPath file = finder.find(moduleClass, moduleLabel);
// will throw if can't find
}
|