Commit 9d849fa4 authored by Timo Koch's avatar Timo Koch
Browse files

[loggingtree] Fix getSubGroups for empty key

parent 12d0c7d3
......@@ -128,15 +128,18 @@ public:
std::string groupPrefix) const
{
std::vector<std::string> groupNames;
auto compoundGroup = groupPrefix.empty() ? subGroupName : groupPrefix + "." + subGroupName;
for (std::string::size_type dotPos = 0; dotPos != std::string::npos; dotPos = groupPrefix.rfind("."))
if (!groupPrefix.empty())
{
if (params_.hasSub(compoundGroup) || defaultParams_.hasSub(compoundGroup))
groupNames.push_back(compoundGroup);
auto compoundGroup = groupPrefix + "." + subGroupName;
for (std::string::size_type dotPos = 0; dotPos != std::string::npos; dotPos = groupPrefix.rfind("."))
{
if (params_.hasSub(compoundGroup) || defaultParams_.hasSub(compoundGroup))
groupNames.push_back(compoundGroup);
groupPrefix = groupPrefix.substr(0, dotPos);
compoundGroup = groupPrefix + "." + subGroupName;
groupPrefix = groupPrefix.substr(0, dotPos);
compoundGroup = groupPrefix + "." + subGroupName;
}
}
if (params_.hasSub(subGroupName) || defaultParams_.hasSub(subGroupName))
......
......@@ -46,13 +46,20 @@ int main (int argc, char *argv[]) try
if (tEnd != 1e6) DUNE_THROW(Dune::InvalidStateException, "TEnd should be 1e6!");
auto groups = getParamSubGroups("TimeLoop", "Bulk");
std::cout << "Found the following TimeLoop groups: ";
std::cout << "Found the following TimeLoop groups (group: Bulk): ";
for (const auto& g : groups) std::cout << g << " ";
std::cout << std::endl;
if (groups.size() != 2) DUNE_THROW(Dune::InvalidStateException, "Wrong number of groups with ending name TimeLoop! (" << groups.size() << ", should be 2)");
if (groups[0] != "Bulk.TimeLoop") DUNE_THROW(Dune::InvalidStateException, "Wrong order or name of subgroups with ending name TimeLoop!");
if (groups[1] != "TimeLoop") DUNE_THROW(Dune::InvalidStateException, "Wrong order or name of subgroups with ending name TimeLoop!");
groups = getParamSubGroups("TimeLoop", "");
std::cout << "Found the following TimeLoop groups (group: empty): ";
for (const auto& g : groups) std::cout << g << " ";
std::cout << std::endl;
if (groups.size() != 1) DUNE_THROW(Dune::InvalidStateException, "Wrong number of groups with ending name TimeLoop! (" << groups.size() << ", should be 1)");
if (groups[0] != "TimeLoop") DUNE_THROW(Dune::InvalidStateException, "Wrong order or name of subgroups with ending name TimeLoop!");
Parameters::print();
// check the unused keys
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment