From 7324a5c91849caffb932d3a874ee4c719afe44ed Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sat, 20 Jun 2015 05:38:10 -0400 Subject: [PATCH] add test --- tests/bits/parameter_handler_20.cc | 64 ++++++++++++++++++++++++++ tests/bits/parameter_handler_20.output | 11 +++++ 2 files changed, 75 insertions(+) create mode 100644 tests/bits/parameter_handler_20.cc create mode 100644 tests/bits/parameter_handler_20.output diff --git a/tests/bits/parameter_handler_20.cc b/tests/bits/parameter_handler_20.cc new file mode 100644 index 0000000000..3c2600f32e --- /dev/null +++ b/tests/bits/parameter_handler_20.cc @@ -0,0 +1,64 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2002 - 2014 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. +// +// --------------------------------------------------------------------- + + + +// ParameterHandler seemed to ignore everything on the same line behind "end", +// we should generate an error instead. + +#include "../tests.h" +#include +#include +#include + +void check (const char * content) +{ + deallog << "* check" << std::endl; + ParameterHandler foo; + foo.enter_subsection("bar"); + foo.declare_entry("val", "1.0", dealii::Patterns::Double(), ""); + foo.leave_subsection(); + foo.declare_entry("val2", "2.0", dealii::Patterns::Double(), ""); + + std::stringstream ss(content); + + if (!foo.read_input(ss)) + { + deallog << "read_input() failed" << std::endl; + return; + } + + deallog << "input: "; + foo.enter_subsection("bar"); + deallog << foo.get_double ("val") << " "; + foo.leave_subsection(); + deallog << foo.get_double ("val2") << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check ("subsection bar\nend #comment is okay"); + check ("subsection bar\nend "); + check ("subsection bar\nendhello what is this?"); + check ("subsection bar\nendset val2=-3"); + check ("subsection bar\nendset val2=-3\nset val2=-2"); + + return 0; +} diff --git a/tests/bits/parameter_handler_20.output b/tests/bits/parameter_handler_20.output new file mode 100644 index 0000000000..68e6af9fce --- /dev/null +++ b/tests/bits/parameter_handler_20.output @@ -0,0 +1,11 @@ + +DEAL::* check +DEAL::input: 1.00000 2.00000 +DEAL::* check +DEAL::input: 1.00000 2.00000 +DEAL::* check +DEAL::read_input() failed +DEAL::* check +DEAL::read_input() failed +DEAL::* check +DEAL::read_input() failed -- 2.39.5