Skip to content

Commit

Permalink
Merge pull request #44034 from Dr15Jones/unittest_cleanup_FWCoreFrame…
Browse files Browse the repository at this point in the history
…work

Improved unit tests in FWCore/Framework
  • Loading branch information
cmsbuild authored Feb 21, 2024
2 parents 6ef2ab4 + 97a27fb commit 34c2769
Show file tree
Hide file tree
Showing 10 changed files with 516 additions and 616 deletions.
43 changes: 3 additions & 40 deletions FWCore/Framework/src/TriggerResultsBasedEventSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@

static const edm::TypeID s_TrigResultsType(typeid(edm::TriggerResults));

namespace {
namespace trigger_results_based_event_selector_utils {
//--------------------------------------------------------
// Remove whitespace (spaces and tabs) from a std::string.
void remove_whitespace(std::string& s) {
s.erase(std::remove(s.begin(), s.end(), ' '), s.end());
s.erase(std::remove(s.begin(), s.end(), '\t'), s.end());
}

void test_remove_whitespace() {
std::string a("noblanks");
std::string b("\t no blanks \t");

remove_whitespace(b);
assert(a == b);
}

//--------------------------------------------------------
// Given a path-spec (std::string of the form "a:b", where the ":b" is
// optional), return a parsed_path_spec_t containing "a" and "b".
Expand All @@ -40,40 +32,11 @@ namespace {
output.second = trimmed_path_spec.substr(colon + 1, trimmed_path_spec.size());
}
}
} // namespace trigger_results_based_event_selector_utils

void test_parse_path_spec() {
std::vector<std::string> paths;
paths.push_back("a:p1");
paths.push_back("b:p2");
paths.push_back(" c");
paths.push_back("ddd\t:p3");
paths.push_back("eee: p4 ");

std::vector<parsed_path_spec_t> parsed(paths.size());
for (size_t i = 0; i < paths.size(); ++i) {
parse_path_spec(paths[i], parsed[i]);
}

assert(parsed[0].first == "a");
assert(parsed[0].second == "p1");
assert(parsed[1].first == "b");
assert(parsed[1].second == "p2");
assert(parsed[2].first == "c");
assert(parsed[2].second.empty());
assert(parsed[3].first == "ddd");
assert(parsed[3].second == "p3");
assert(parsed[4].first == "eee");
assert(parsed[4].second == "p4");
}
} // namespace
using namespace trigger_results_based_event_selector_utils;

namespace edm {
namespace test {
void run_all_output_module_tests() {
test_remove_whitespace();
test_parse_path_spec();
}
} // namespace test

namespace detail {

Expand Down
39 changes: 6 additions & 33 deletions FWCore/Framework/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,53 +271,26 @@

<test name="TestXMLSafeException" command="run_XMLException.sh"/>

<bin name="TestFWCoreFrameworkProductSelector" file="ProductSelector_t.cpp">
<bin name="TestFWCoreFrameworkProductSelector" file="test_catch2_main.cc,ProductSelector_t.cpp">
<use name="DataFormats/Provenance"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<use name="catch2"/>
</bin>

<bin name="TestFWCoreFrameworkEventSelector" file="EventSelector_t.cpp">
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
</bin>

<bin name="TestFWCoreFrameworkEventSelWildcard" file="EventSelWildcard_t.cpp">
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
</bin>

<bin name="TestFWCoreFrameworkEventSelExc" file="EventSelExc_t.cpp">
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
</bin>

<bin name="TestFWCoreFrameworkEventSelOverlap" file="EventSelOverlap_t.cpp">
<bin name="TestFWCoreFrameworkEventSelector" file="test_catch2_main.cc,EventSel*_t.cpp">
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
<use name="catch2"/>
</bin>

<bin name="TestFWCoreFrameworkRegistryTemplate" file="RegistryTemplate_t.cpp">
<use name="DataFormats/Provenance"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
</bin>

<bin name="TestFWCoreOutputModuleUtilities" file="OutputModuleUtilities_t.cpp">
<bin name="TestFWCoreTriggerResultsBasedEventSelectorUtilities" file="test_catch2_main.cc,TriggerResultsBasedEventSelectorUtilities_t.cpp">
<use name="FWCore/Framework"/>
<use name="catch2"/>
</bin>

<bin name="TestFWCoreFrameworkStatemachine" file="statemachine_t.cc">
Expand Down
Loading

0 comments on commit 34c2769

Please sign in to comment.