From: Wolfgang Bangerth Date: Sun, 22 Mar 2015 23:14:05 +0000 (-0500) Subject: Add more tests. X-Git-Tag: v8.3.0-rc1~358^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ba78394b3d1bd509da06127490742b8efc2c848;p=dealii.git Add more tests. --- diff --git a/tests/bits/parameter_handler_3_with_alias_03.cc b/tests/bits/parameter_handler_3_with_alias_03.cc new file mode 100644 index 0000000000..b4eb3525ec --- /dev/null +++ b/tests/bits/parameter_handler_3_with_alias_03.cc @@ -0,0 +1,84 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2003 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// like _with_alias_02 but read an input file that references both the old and +// the new parameter + +#include "../tests.h" +#include +#include +#include +#include + + +int main () +{ + try + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.enter_subsection ("Testing"); + prm.declare_entry ("string list", + "a", + Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")), + "docs 1"); + prm.declare_entry ("int_alias", + "1", + Patterns::Integer()); + prm.declare_entry ("double", + "3.1415926", + Patterns::Double(), + "docs 3"); + prm.declare_alias ("int_alias", + "int"); + prm.leave_subsection (); + + // read and then write parameters + prm.read_input(SOURCE_DIR "/prm/parameter_handler_3_with_alias_03.prm"); + prm.print_parameters (logfile, ParameterHandler::Text); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; + + return 0; +} diff --git a/tests/bits/parameter_handler_3_with_alias_03.output b/tests/bits/parameter_handler_3_with_alias_03.output new file mode 100644 index 0000000000..4d123c17b5 --- /dev/null +++ b/tests/bits/parameter_handler_3_with_alias_03.output @@ -0,0 +1,13 @@ + +# Listing of Parameters +# --------------------- +subsection Testing + # docs 3 + set double = 3.1415926 + set int_alias = 3 # default: 1 + + # docs 1 + set string list = a, b, c # default: a +end + + diff --git a/tests/bits/parameter_handler_3_with_alias_04.cc b/tests/bits/parameter_handler_3_with_alias_04.cc new file mode 100644 index 0000000000..87d2ea669c --- /dev/null +++ b/tests/bits/parameter_handler_3_with_alias_04.cc @@ -0,0 +1,84 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2003 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// like _with_alias_02 but read an input file that references both the old and +// the new parameter (in the opposite order of the _with_alias_03 test) + +#include "../tests.h" +#include +#include +#include +#include + + +int main () +{ + try + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.enter_subsection ("Testing"); + prm.declare_entry ("string list", + "a", + Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")), + "docs 1"); + prm.declare_entry ("int_alias", + "1", + Patterns::Integer()); + prm.declare_entry ("double", + "3.1415926", + Patterns::Double(), + "docs 3"); + prm.declare_alias ("int_alias", + "int"); + prm.leave_subsection (); + + // read and then write parameters + prm.read_input(SOURCE_DIR "/prm/parameter_handler_3_with_alias_04.prm"); + prm.print_parameters (logfile, ParameterHandler::Text); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; + + return 0; +} diff --git a/tests/bits/parameter_handler_3_with_alias_04.output b/tests/bits/parameter_handler_3_with_alias_04.output new file mode 100644 index 0000000000..c27430f5e1 --- /dev/null +++ b/tests/bits/parameter_handler_3_with_alias_04.output @@ -0,0 +1,13 @@ + +# Listing of Parameters +# --------------------- +subsection Testing + # docs 3 + set double = 3.1415926 + set int_alias = 4 # default: 1 + + # docs 1 + set string list = a, b, c # default: a +end + + diff --git a/tests/bits/parameter_handler_4a_with_alias.cc b/tests/bits/parameter_handler_4a_with_alias.cc new file mode 100644 index 0000000000..a567c1426a --- /dev/null +++ b/tests/bits/parameter_handler_4a_with_alias.cc @@ -0,0 +1,104 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2003 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test the output generated by +// ParameterHandler::print_parameters(LaTeX). like the _4a test but +// with aliased parameters + +#include "../tests.h" +#include +#include +#include +#include + + +int main () +{ + try + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.enter_subsection ("Testing"); + { + prm.enter_subsection ("Testing 2"); + { + prm.declare_entry ("string list 2", + "a", + Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")), + "docs 1"); + prm.declare_entry ("int 2", + "1", + Patterns::Integer()); + prm.declare_entry ("double 2", + "3.1415926", + Patterns::Double(), + "docs 3"); + } + prm.leave_subsection (); + + prm.declare_entry ("string list", + "a", + Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")), + "docs 1"); + prm.declare_entry ("int", + "1", + Patterns::Integer()); + prm.declare_entry ("double", + "3.1415926", + Patterns::Double(), + "docs 3"); + } + prm.leave_subsection (); + + // read and then write + // parameters. take same input file + // as for parameter_handler_3, but + // use different output format + prm.read_input(SOURCE_DIR "/prm/parameter_handler_3.prm"); + prm.print_parameters (logfile, ParameterHandler::LaTeX); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; + + return 0; +} diff --git a/tests/bits/parameter_handler_4a_with_alias.output b/tests/bits/parameter_handler_4a_with_alias.output new file mode 100644 index 0000000000..6dcf0739c9 --- /dev/null +++ b/tests/bits/parameter_handler_4a_with_alias.output @@ -0,0 +1,109 @@ + +\subsection{Global parameters} +\label{parameters:global} + + + +\subsection{Parameters in section \tt Testing} +\label{parameters:Testing} + +\begin{itemize} +\item {\it Parameter name:} {\tt double} +\phantomsection\label{parameters:Testing/double} + + +\index[prmindex]{double} +\index[prmindexfull]{Testing!double} +{\it Value:} 3.1415926 + + +{\it Default:} 3.1415926 + + +{\it Description:} docs 3 + + +{\it Possible values:} [Double -1.79769e+308...1.79769e+308 (inclusive)] +\item {\it Parameter name:} {\tt int} +\phantomsection\label{parameters:Testing/int} + + +\index[prmindex]{int} +\index[prmindexfull]{Testing!int} +{\it Value:} 3 + + +{\it Default:} 1 + + +{\it Possible values:} [Integer range -2147483648...2147483647 (inclusive)] +\item {\it Parameter name:} {\tt string list} +\phantomsection\label{parameters:Testing/string list} + + +\index[prmindex]{string list} +\index[prmindexfull]{Testing!string list} +{\it Value:} a, b, c + + +{\it Default:} a + + +{\it Description:} docs 1 + + +{\it Possible values:} [List list of <[Selection a|b|c|d|e|f|g|h ]> of length 0...4294967295 (inclusive)] +\end{itemize} + + + +\subsection{Parameters in section \tt Testing/Testing 2} +\label{parameters:Testing/Testing_202} + +\begin{itemize} +\item {\it Parameter name:} {\tt double 2} +\phantomsection\label{parameters:Testing/Testing 2/double 2} + + +\index[prmindex]{double 2} +\index[prmindexfull]{Testing!Testing 2!double 2} +{\it Value:} 3.1415926 + + +{\it Default:} 3.1415926 + + +{\it Description:} docs 3 + + +{\it Possible values:} [Double -1.79769e+308...1.79769e+308 (inclusive)] +\item {\it Parameter name:} {\tt int 2} +\phantomsection\label{parameters:Testing/Testing 2/int 2} + + +\index[prmindex]{int 2} +\index[prmindexfull]{Testing!Testing 2!int 2} +{\it Value:} 1 + + +{\it Default:} 1 + + +{\it Possible values:} [Integer range -2147483648...2147483647 (inclusive)] +\item {\it Parameter name:} {\tt string list 2} +\phantomsection\label{parameters:Testing/Testing 2/string list 2} + + +\index[prmindex]{string list 2} +\index[prmindexfull]{Testing!Testing 2!string list 2} +{\it Value:} a + + +{\it Default:} a + + +{\it Description:} docs 1 + + +{\it Possible values:} [List list of <[Selection a|b|c|d|e|f|g|h ]> of length 0...4294967295 (inclusive)] +\end{itemize} diff --git a/tests/bits/prm/parameter_handler_3_with_alias_03.prm b/tests/bits/prm/parameter_handler_3_with_alias_03.prm new file mode 100644 index 0000000000..9f0071796c --- /dev/null +++ b/tests/bits/prm/parameter_handler_3_with_alias_03.prm @@ -0,0 +1,5 @@ +subsection Testing + set string list = a, b, c + set int_alias = 4 + set int = 3 +end diff --git a/tests/bits/prm/parameter_handler_3_with_alias_04.prm b/tests/bits/prm/parameter_handler_3_with_alias_04.prm new file mode 100644 index 0000000000..e30ce61ccd --- /dev/null +++ b/tests/bits/prm/parameter_handler_3_with_alias_04.prm @@ -0,0 +1,5 @@ +subsection Testing + set string list = a, b, c + set int = 3 + set int_alias = 4 +end