]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new tests for ParameterHandler print_parameters_section
authorsteigemann <steigemann@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 1 Feb 2014 08:04:39 +0000 (08:04 +0000)
committersteigemann <steigemann@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 1 Feb 2014 08:04:39 +0000 (08:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@32364 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/parameter_handler_write_section_1.cc [new file with mode: 0644]
tests/bits/parameter_handler_write_section_1.output [new file with mode: 0644]
tests/bits/parameter_handler_write_section_2.cc [new file with mode: 0644]
tests/bits/parameter_handler_write_section_2.output [new file with mode: 0644]
tests/bits/parameter_handler_write_section_xml.cc [new file with mode: 0644]
tests/bits/parameter_handler_write_section_xml.output [new file with mode: 0644]

diff --git a/tests/bits/parameter_handler_write_section_1.cc b/tests/bits/parameter_handler_write_section_1.cc
new file mode 100644 (file)
index 0000000..69351b0
--- /dev/null
@@ -0,0 +1,79 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few
+// names that contain all sorts of weird (for XML) characters
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+  std::ofstream logfile("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.enter_subsection ("ss1");
+  {
+    prm.declare_entry ("double 1",
+                       "1.234",
+                       Patterns::Double(),
+                       "doc 3");
+
+    // things with strange characters
+    prm.enter_subsection ("Testing%testing");
+    {
+      prm.declare_entry ("double 2",
+                         "4.321",
+                         Patterns::Double(),
+                         "doc 4");
+      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 ();
+  }
+  prm.leave_subsection ();
+
+  prm.enter_subsection ("ss1");
+  prm.enter_subsection ("Testing%testing");
+  prm.print_parameters_section (logfile, ParameterHandler::Text, 0);
+  prm.leave_subsection ();
+  prm.leave_subsection ();
+
+  logfile << std::endl;
+
+  return 0;
+}
diff --git a/tests/bits/parameter_handler_write_section_1.output b/tests/bits/parameter_handler_write_section_1.output
new file mode 100644 (file)
index 0000000..ddcb05b
--- /dev/null
@@ -0,0 +1,11 @@
+
+# doc 4
+set double 2      = 4.321
+
+# docs 3
+set double+double = 6.1415926
+set int*int       = 2
+
+# docs 1
+set string&list   = < & > ; /
+
diff --git a/tests/bits/parameter_handler_write_section_2.cc b/tests/bits/parameter_handler_write_section_2.cc
new file mode 100644 (file)
index 0000000..80763c7
--- /dev/null
@@ -0,0 +1,79 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few
+// names that contain all sorts of weird (for XML) characters
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+  std::ofstream logfile("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.enter_subsection ("ss1");
+  {
+    prm.declare_entry ("double 1",
+                       "1.234",
+                       Patterns::Double(),
+                       "doc 3");
+
+    // things with strange characters
+    prm.enter_subsection ("Testing%testing");
+    {
+      prm.declare_entry ("double 2",
+                         "4.321",
+                         Patterns::Double(),
+                         "doc 4");
+      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 ();
+  }
+  prm.leave_subsection ();
+
+  prm.enter_subsection ("ss1");
+  prm.enter_subsection ("Testing%testing");
+  prm.print_parameters_section (logfile, ParameterHandler::Text, 0, true);
+  prm.leave_subsection ();
+  prm.leave_subsection ();
+
+  logfile << std::endl;
+
+  return 0;
+}
diff --git a/tests/bits/parameter_handler_write_section_2.output b/tests/bits/parameter_handler_write_section_2.output
new file mode 100644 (file)
index 0000000..2312214
--- /dev/null
@@ -0,0 +1,15 @@
+
+subsection ss1
+  subsection Testing%testing
+    # doc 4
+    set double 2      = 4.321
+
+    # docs 3
+    set double+double = 6.1415926
+    set int*int       = 2
+
+    # docs 1
+    set string&list   = < & > ; /
+  end
+end
+
diff --git a/tests/bits/parameter_handler_write_section_xml.cc b/tests/bits/parameter_handler_write_section_xml.cc
new file mode 100644 (file)
index 0000000..da219d1
--- /dev/null
@@ -0,0 +1,79 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a few
+// names that contain all sorts of weird (for XML) characters
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+  std::ofstream logfile("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.enter_subsection ("ss1");
+  {
+    prm.declare_entry ("double 1",
+                       "1.234",
+                       Patterns::Double(),
+                       "doc 3");
+
+    // things with strange characters
+    prm.enter_subsection ("Testing%testing");
+    {
+      prm.declare_entry ("double 2",
+                         "4.321",
+                         Patterns::Double(),
+                         "doc 4");
+      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 ();
+  }
+  prm.leave_subsection ();
+
+  prm.enter_subsection ("ss1");
+  prm.enter_subsection ("Testing%testing");
+  prm.print_parameters_section (logfile, ParameterHandler::XML, 0, true);
+  prm.leave_subsection ();
+  prm.leave_subsection ();
+
+  logfile << std::endl;
+
+  return 0;
+}
diff --git a/tests/bits/parameter_handler_write_section_xml.output b/tests/bits/parameter_handler_write_section_xml.output
new file mode 100644 (file)
index 0000000..d9345a9
--- /dev/null
@@ -0,0 +1,3 @@
+
+<?xml version="1.0" encoding="utf-8"?>
+<ParameterHandler><ss1><Testing_25testing><double_202><value>4.321</value><default_value>4.321</default_value><documentation>doc 4</documentation><pattern>2</pattern><pattern_description>[Double -1.79769e+308...1.79769e+308 (inclusive)]</pattern_description></double_202><string_26list><value>&lt; &amp; &gt; ; /</value><default_value>&lt; &amp; &gt; ; /</default_value><documentation>docs 1</documentation><pattern>3</pattern><pattern_description>[Anything]</pattern_description></string_26list><int_2aint><value>2</value><default_value>2</default_value><documentation/><pattern>4</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description></int_2aint><double_2bdouble><value>6.1415926</value><default_value>6.1415926</default_value><documentation>docs 3</documentation><pattern>5</pattern><pattern_description>[Double -1.79769e+308...1.79769e+308 (inclusive)]</pattern_description></double_2bdouble></Testing_25testing></ss1></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.