From: steigemann Date: Sat, 1 Feb 2014 08:04:39 +0000 (+0000) Subject: new tests for ParameterHandler print_parameters_section X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe31994915ca5d8f0ea4dc7fc91f30abffa6d116;p=dealii-svn.git new tests for ParameterHandler print_parameters_section git-svn-id: https://svn.dealii.org/trunk@32364 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/parameter_handler_write_section_1.cc b/tests/bits/parameter_handler_write_section_1.cc new file mode 100644 index 0000000000..69351b09b9 --- /dev/null +++ b/tests/bits/parameter_handler_write_section_1.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few +// names that contain all sorts of weird (for XML) characters + +#include "../tests.h" +#include +#include +#include + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.declare_entry ("int1", + "1", + Patterns::Integer(), + "doc 1"); + prm.enter_subsection ("ss1"); + { + prm.declare_entry ("double 1", + "1.234", + Patterns::Double(), + "doc 3"); + + // things with strange characters + prm.enter_subsection ("Testing%testing"); + { + prm.declare_entry ("double 2", + "4.321", + Patterns::Double(), + "doc 4"); + prm.declare_entry ("string&list", + "< & > ; /", + Patterns::Anything(), + "docs 1"); + prm.declare_entry ("int*int", + "2", + Patterns::Integer()); + prm.declare_entry ("double+double", + "6.1415926", + Patterns::Double(), + "docs 3"); + } + prm.leave_subsection (); + } + prm.leave_subsection (); + + prm.enter_subsection ("ss1"); + prm.enter_subsection ("Testing%testing"); + prm.print_parameters_section (logfile, ParameterHandler::Text, 0); + prm.leave_subsection (); + prm.leave_subsection (); + + logfile << std::endl; + + return 0; +} diff --git a/tests/bits/parameter_handler_write_section_1.output b/tests/bits/parameter_handler_write_section_1.output new file mode 100644 index 0000000000..ddcb05bbb2 --- /dev/null +++ b/tests/bits/parameter_handler_write_section_1.output @@ -0,0 +1,11 @@ + +# doc 4 +set double 2 = 4.321 + +# docs 3 +set double+double = 6.1415926 +set int*int = 2 + +# docs 1 +set string&list = < & > ; / + diff --git a/tests/bits/parameter_handler_write_section_2.cc b/tests/bits/parameter_handler_write_section_2.cc new file mode 100644 index 0000000000..80763c747c --- /dev/null +++ b/tests/bits/parameter_handler_write_section_2.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few +// names that contain all sorts of weird (for XML) characters + +#include "../tests.h" +#include +#include +#include + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.declare_entry ("int1", + "1", + Patterns::Integer(), + "doc 1"); + prm.enter_subsection ("ss1"); + { + prm.declare_entry ("double 1", + "1.234", + Patterns::Double(), + "doc 3"); + + // things with strange characters + prm.enter_subsection ("Testing%testing"); + { + prm.declare_entry ("double 2", + "4.321", + Patterns::Double(), + "doc 4"); + prm.declare_entry ("string&list", + "< & > ; /", + Patterns::Anything(), + "docs 1"); + prm.declare_entry ("int*int", + "2", + Patterns::Integer()); + prm.declare_entry ("double+double", + "6.1415926", + Patterns::Double(), + "docs 3"); + } + prm.leave_subsection (); + } + prm.leave_subsection (); + + prm.enter_subsection ("ss1"); + prm.enter_subsection ("Testing%testing"); + prm.print_parameters_section (logfile, ParameterHandler::Text, 0, true); + prm.leave_subsection (); + prm.leave_subsection (); + + logfile << std::endl; + + return 0; +} diff --git a/tests/bits/parameter_handler_write_section_2.output b/tests/bits/parameter_handler_write_section_2.output new file mode 100644 index 0000000000..2312214379 --- /dev/null +++ b/tests/bits/parameter_handler_write_section_2.output @@ -0,0 +1,15 @@ + +subsection ss1 + subsection Testing%testing + # doc 4 + set double 2 = 4.321 + + # docs 3 + set double+double = 6.1415926 + set int*int = 2 + + # docs 1 + set string&list = < & > ; / + end +end + diff --git a/tests/bits/parameter_handler_write_section_xml.cc b/tests/bits/parameter_handler_write_section_xml.cc new file mode 100644 index 0000000000..da219d14fd --- /dev/null +++ b/tests/bits/parameter_handler_write_section_xml.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few +// names that contain all sorts of weird (for XML) characters + +#include "../tests.h" +#include +#include +#include + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.declare_entry ("int1", + "1", + Patterns::Integer(), + "doc 1"); + prm.enter_subsection ("ss1"); + { + prm.declare_entry ("double 1", + "1.234", + Patterns::Double(), + "doc 3"); + + // things with strange characters + prm.enter_subsection ("Testing%testing"); + { + prm.declare_entry ("double 2", + "4.321", + Patterns::Double(), + "doc 4"); + prm.declare_entry ("string&list", + "< & > ; /", + Patterns::Anything(), + "docs 1"); + prm.declare_entry ("int*int", + "2", + Patterns::Integer()); + prm.declare_entry ("double+double", + "6.1415926", + Patterns::Double(), + "docs 3"); + } + prm.leave_subsection (); + } + prm.leave_subsection (); + + prm.enter_subsection ("ss1"); + prm.enter_subsection ("Testing%testing"); + prm.print_parameters_section (logfile, ParameterHandler::XML, 0, true); + prm.leave_subsection (); + prm.leave_subsection (); + + logfile << std::endl; + + return 0; +} diff --git a/tests/bits/parameter_handler_write_section_xml.output b/tests/bits/parameter_handler_write_section_xml.output new file mode 100644 index 0000000000..d9345a9d22 --- /dev/null +++ b/tests/bits/parameter_handler_write_section_xml.output @@ -0,0 +1,3 @@ + + +4.3214.321doc 42[Double -1.79769e+308...1.79769e+308 (inclusive)]< & > ; /< & > ; /docs 13[Anything]224[Integer range -2147483648...2147483647 (inclusive)]6.14159266.1415926docs 35[Double -1.79769e+308...1.79769e+308 (inclusive)]