]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Dec 2010 14:07:20 +0000 (14:07 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Dec 2010 14:07:20 +0000 (14:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@23022 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/parameter_handler_read_xml_error_01.cc [new file with mode: 0644]
tests/bits/parameter_handler_read_xml_error_01/cmp/generic [new file with mode: 0644]
tests/bits/parameter_handler_read_xml_error_01/prm [new file with mode: 0644]

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 (file)
index 0000000..1a5566d
--- /dev/null
@@ -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 <base/logstream.h>
+#include <base/parameter_handler.h>
+#include <fstream>
+
+
+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 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -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 (file)
index 0000000..850a79a
--- /dev/null
@@ -0,0 +1,4 @@
+
+<?xml version="1.0" encoding="utf-8"?>
+<ParameterHandler><int1234><value>2</value><default_value>1</default_value><documentation>doc 1</documentation><pattern>0</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description></int1><int2><value>3</value><default_value>2</default_value><documentation>doc 2</documentation><pattern>1</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description></int2><ss1><double_201><value>2.234</value><default_value>1.234</default_value><documentation>doc 3</documentation><pattern>2</pattern><pattern_description>[Double -1.79769e+308...1.79769e+308 (inclusive)]</pattern_description></double_201><ss2><double_202><value>5.321</value><default_value>4.321</default_value><documentation>doc 4</documentation><pattern>3</pattern><pattern_description>[Double -1.79769e+308...1.79769e+308 (inclusive)]</pattern_description></double_202></ss2></ss1><Testing_25testing><string_26list><value>__&lt; &amp; &gt; ; /</value><default_value>&lt; &amp; &gt; ; /</default_value><documentation>docs 1</documentation><pattern>4</pattern><pattern_description>[Anything]</pattern_description></string_26list><int_2aint><value>__2</value><default_value>2</default_value><documentation/>
+<pattern>5</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description></int_2aint><double_2bdouble><value>7.1415926</value><default_value>6.1415926</default_value><documentation>docs 3</documentation><pattern>6</pattern><pattern_description>[Double -1.79769e+308...1.79769e+308 (inclusive)]</pattern_description></double_2bdouble></Testing_25testing></ParameterHandler>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.