From 9b56158d8fda56b5821ce1a3dd01c2694d8cfb1e Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 1 Nov 2013 11:27:01 +0000 Subject: [PATCH] add test git-svn-id: https://svn.dealii.org/trunk@31502 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/parameter_handler_15.cc | 74 ++++++++++++++++++++++++++ tests/bits/parameter_handler_15.output | 17 ++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/bits/parameter_handler_15.cc create mode 100644 tests/bits/parameter_handler_15.output diff --git a/tests/bits/parameter_handler_15.cc b/tests/bits/parameter_handler_15.cc new file mode 100644 index 0000000000..bd9ce5f577 --- /dev/null +++ b/tests/bits/parameter_handler_15.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// $Id: parameter_handler_14.cc 31349 2013-10-20 19:07:06Z maier $ +// +// 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. +// +// --------------------------------------------------------------------- + + + +// ParameterHandler could not deal missing endline at end of file +// or can it? +// http://code.google.com/p/dealii/issues/detail?id=126 + +#include "../tests.h" +#include +#include +#include + +void check (const char * content, double &v1, double &v2) +{ + 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); + + foo.read_input(ss); + + + + foo.enter_subsection("bar"); + deallog << foo.get ("val") << std::endl; + v1 = foo.get_double("val"); + foo.leave_subsection(); + deallog << foo.get ("val2") << std::endl; + v2 = foo.get_double("val2"); +} + +void test(std::string content) +{ + double v1,v2; + check((content+"\n").c_str(),v1,v2); + double v3,v4; + check(content.c_str(),v3,v4); + + Assert(v1==v3, ExcInternalError()); + Assert(v2==v4, ExcInternalError()); +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test ("subsection bar\nend"); + test (""); + test ("set val2=-3"); + test ("subsection bar\n set val=2\nend"); + + return 0; +} diff --git a/tests/bits/parameter_handler_15.output b/tests/bits/parameter_handler_15.output new file mode 100644 index 0000000000..9bae611912 --- /dev/null +++ b/tests/bits/parameter_handler_15.output @@ -0,0 +1,17 @@ + +DEAL::1.0 +DEAL::2.0 +DEAL::1.0 +DEAL::2.0 +DEAL::1.0 +DEAL::2.0 +DEAL::1.0 +DEAL::2.0 +DEAL::1.0 +DEAL::-3 +DEAL::1.0 +DEAL::-3 +DEAL::2 +DEAL::2.0 +DEAL::2 +DEAL::2.0 -- 2.39.5