Skip to content
Snippets Groups Projects
Commit aa980318 authored by Christian Engwer's avatar Christian Engwer
Browse files

[test] add a test for the report method of the parametertree

parent c8580cd0
No related branches found
No related tags found
No related merge requests found
......@@ -245,6 +245,35 @@ void testFS1523()
check_assert(ptree.get<int>("setting") == -1);
}
void check_recursiveTreeCompare(const Dune::ParameterTree & p1,
const Dune::ParameterTree & p2)
{
check_assert(p1.getValueKeys() == p2.getValueKeys());
check_assert(p1.getSubKeys() == p2.getSubKeys());
typedef Dune::ParameterTree::KeyVector::const_iterator Iterator;
for (Iterator it = p1.getValueKeys().begin();
it != p1.getValueKeys().end(); ++it)
check_assert(p1[*it] == p2[*it]);
for (Iterator it = p1.getSubKeys().begin();
it != p1.getSubKeys().end(); ++it)
check_recursiveTreeCompare(p1.sub(*it), p2.sub(*it));
}
// test report method and read back in
void testReport()
{
std::stringstream s;
s << "foo.i = 1 \n foo.bar.peng = hurz";
Dune::ParameterTree ptree;
Dune::ParameterTreeParser::readINITree(s, ptree);
std::stringstream s2;
ptree.report(s2);
Dune::ParameterTree ptree2;
Dune::ParameterTreeParser::readINITree(s2, ptree2);
check_recursiveTreeCompare(ptree, ptree2);
}
int main()
{
try {
......@@ -275,6 +304,9 @@ int main()
// check the command line parser
testOptionsParser();
// check report
testReport();
// check for specific bugs
testFS1527();
testFS1523();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment