From 889b851230db35869c6c6107a947e6593479b3bc Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 20 Dec 2010 14:07:20 +0000 Subject: [PATCH] Add test. git-svn-id: https://svn.dealii.org/trunk@23022 0785d39b-7218-0410-832d-ea1e28bc413d --- .../parameter_handler_read_xml_error_01.cc | 83 +++++++++++++++++++ .../cmp/generic | 2 + .../parameter_handler_read_xml_error_01/prm | 4 + 3 files changed, 89 insertions(+) create mode 100644 tests/bits/parameter_handler_read_xml_error_01.cc create mode 100644 tests/bits/parameter_handler_read_xml_error_01/cmp/generic create mode 100644 tests/bits/parameter_handler_read_xml_error_01/prm diff --git a/tests/bits/parameter_handler_read_xml_error_01.cc b/tests/bits/parameter_handler_read_xml_error_01.cc new file mode 100644 index 0000000000..1a5566dfe4 --- /dev/null +++ b/tests/bits/parameter_handler_read_xml_error_01.cc @@ -0,0 +1,83 @@ +//---------------------------- parameter_handler_read_xml_error_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2002, 2003, 2004, 2005, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- parameter_handler_read_xml_error_01.cc --------------------------- + + +// check ParameterHandler::read_input_from_xml. try to read a file with a +// parameter that has not been declared + +#include "../tests.h" +#include +#include +#include + + +int main () +{ + std::ofstream logfile("parameter_handler_read_xml_error_01/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.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 (); + + // read from XML + std::ifstream in ("parameter_handler_read_xml_error_01/prm"); + bool result = prm.read_input_from_xml (in); + Assert (result == false, ExcInternalError()); + + deallog << "OK" << std::endl; + + return 0; +} diff --git a/tests/bits/parameter_handler_read_xml_error_01/cmp/generic b/tests/bits/parameter_handler_read_xml_error_01/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/parameter_handler_read_xml_error_01/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/parameter_handler_read_xml_error_01/prm b/tests/bits/parameter_handler_read_xml_error_01/prm new file mode 100644 index 0000000000..850a79ab58 --- /dev/null +++ b/tests/bits/parameter_handler_read_xml_error_01/prm @@ -0,0 +1,4 @@ + + +21doc 10[Integer range -2147483648...2147483647 (inclusive)]32doc 21[Integer range -2147483648...2147483647 (inclusive)]2.2341.234doc 32[Double -1.79769e+308...1.79769e+308 (inclusive)]5.3214.321doc 43[Double -1.79769e+308...1.79769e+308 (inclusive)]__< & > ; /< & > ; /docs 14[Anything]__22 +5[Integer range -2147483648...2147483647 (inclusive)]7.14159266.1415926docs 36[Double -1.79769e+308...1.79769e+308 (inclusive)] -- 2.39.5