From: Wolfgang Bangerth Date: Sat, 10 Jun 2017 00:28:45 +0000 (-0600) Subject: Add test. X-Git-Tag: v9.0.0-rc1~1509^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7f2346de1b24579f09db6bf98cb1c4c77222fd0;p=dealii.git Add test. --- diff --git a/tests/parameter_handler/save_flags.cc b/tests/parameter_handler/save_flags.cc new file mode 100644 index 0000000000..091f0feb00 --- /dev/null +++ b/tests/parameter_handler/save_flags.cc @@ -0,0 +1,92 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2002 - 2016 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 that ParameterHandler::print_parameters() saves and resets +// the iostream flags of the stream it writes to + +#include "../tests.h" +#include +#include +#include +#include + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.declare_entry ("int1", + "1", + Patterns::Integer(), + "doc 1"); + prm.declare_entry ("int2", + "2", + Patterns::Integer(), + "doc 2"); + prm.enter_subsection ("ss1"); + { + prm.declare_entry ("double 1", + "1.234", + Patterns::Double(), + "doc 3"); + + prm.enter_subsection ("ss2"); + { + prm.declare_entry ("double 2", + "4.321", + Patterns::Double(), + "doc 4"); + } + prm.leave_subsection (); + } + prm.leave_subsection (); + + // things with strange characters + prm.enter_subsection ("Testing%testing"); + { + 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 (); + + // set a special fill char and verify that it is being used + logfile.fill('x'); + logfile.width(15); + logfile << std::left << 42 << std::endl; + + // now let ParameterHandler output its state + prm.print_parameters (logfile, ParameterHandler::Description); + + // verify that the special fill char is still available (i.e., that + // print_parameters() has saved and restored the stream flags) + logfile.width(15); + logfile << std::left << 42 << std::endl; + + return 0; +} diff --git a/tests/parameter_handler/save_flags.output b/tests/parameter_handler/save_flags.output new file mode 100644 index 0000000000..6f7ee317d1 --- /dev/null +++ b/tests/parameter_handler/save_flags.output @@ -0,0 +1,21 @@ + +42xxxxxxxxxxxxx +Listing of Parameters: + +set int1 = An integer n such that -2147483648 <= n <= 2147483647 + (doc 1) +set int2 = An integer n such that -2147483648 <= n <= 2147483647 + (doc 2) +subsection Testing%testing + set double+double = A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE + (docs 3) + set int*int = An integer n such that -2147483648 <= n <= 2147483647 + set string&list = Any string + (docs 1) +subsection ss1 + set double 1 = A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE + (doc 3) + subsection ss2 + set double 2 = A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE + (doc 4) +42xxxxxxxxxxxxx