Skip to content

Commit 463c06f

Browse files
authored
[QC-1147] Bug in CustomParameters::getAllDefaults (#2239)
* [QC-1147] Bug in CustomParameters::getAllDefaults * format
1 parent 41c4efb commit 463c06f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Framework/src/CustomParameters.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ const std::unordered_map<std::string, std::string>& CustomParameters::getAllForR
5252

5353
const std::unordered_map<std::string, std::string>& CustomParameters::getAllDefaults()
5454
{
55-
return getAllForRunBeam("default", "default");
55+
try {
56+
return getAllForRunBeam("default", "default");
57+
} catch (std::out_of_range outOfRange) {
58+
// we ignore the fact that we could not find anything and return an empty map
59+
return mCustomParameters["null"]["null"];
60+
}
5661
}
5762

5863
std::string CustomParameters::at(const std::string& key, const std::string& runType, const std::string& beamType) const

Framework/test/testCustomParameters.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,10 @@ TEST_CASE("test_default_if_not_found_at")
258258
CHECK(cp.at("key", "TECHNICAL", "STRANGE") == "valueDefaultDefault"); // key is not defined for run nor beam
259259
CHECK(cp.at("key", "TECHNICAL", "PROTON-PROTON") == "valueCosmicsDefault"); // key is not defined for technical
260260
}
261+
262+
TEST_CASE("test_getAllDefaults")
263+
{
264+
CustomParameters cp;
265+
auto result = cp.getAllDefaults();
266+
CHECK(result.size() == 0);
267+
}

0 commit comments

Comments
 (0)