]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed bug in Patterns::Selection
authorsairajat <rajat.arora9464@gmail.com>
Tue, 7 Feb 2017 21:14:58 +0000 (16:14 -0500)
committersairajat <rajat.arora9464@gmail.com>
Tue, 7 Feb 2017 21:14:58 +0000 (16:14 -0500)
source/base/parameter_handler.cc
tests/parameter_handler/parameter_handler_3_with_space.cc [new file with mode: 0644]
tests/parameter_handler/parameter_handler_3_with_space.output [new file with mode: 0644]

index 128e2410b386c8a6cfdaf60aadd3f1f649ee6db1..a0d6c22ead90937a48029b3339d69ca1203da9ae 100644 (file)
@@ -469,7 +469,7 @@ namespace Patterns
     std::string tmp(sequence);
     // remove whitespace at beginning
     while ((tmp.length() != 0) && (std::isspace (tmp[0])))
-      tmp.erase (0,1);
+     tmp.erase (0,1);
 
     // check the different possibilities
     while (tmp.find('|') != std::string::npos)
diff --git a/tests/parameter_handler/parameter_handler_3_with_space.cc b/tests/parameter_handler/parameter_handler_3_with_space.cc
new file mode 100644 (file)
index 0000000..ebff780
--- /dev/null
@@ -0,0 +1,80 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2016 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test the output generated by ParameterHandler::print_parameters(Text)
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+#include <iomanip>
+
+
+int main ()
+{
+  try
+    {
+      std::ofstream logfile("output");
+      deallog.attach(logfile);
+      deallog.threshold_double(1.e-10);
+
+      ParameterHandler prm;
+      prm.enter_subsection ("Testing");
+      prm.declare_entry ("string list",
+                         "a",
+                         Patterns::List(Patterns::Selection(" a|b|c|d|e|f|g|h")),
+                         "docs 1");
+      prm.declare_entry ("int",
+                         "1",
+                         Patterns::Integer());
+      prm.declare_entry ("double",
+                         "3.1415926",
+                         Patterns::Double(),
+                         "docs 3");
+      prm.leave_subsection ();
+
+      // read and then write parameters
+      prm.read_input(SOURCE_DIR "/prm/parameter_handler_3.prm");
+      prm.print_parameters (logfile, ParameterHandler::Text);
+    }
+  catch (std::exception &exc)
+    {
+      deallog << std::endl << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Exception on processing: " << std::endl
+              << exc.what() << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      deallog << std::endl << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Unknown exception!" << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      return 1;
+    };
+
+  return 0;
+}
diff --git a/tests/parameter_handler/parameter_handler_3_with_space.output b/tests/parameter_handler/parameter_handler_3_with_space.output
new file mode 100644 (file)
index 0000000..cf97eae
--- /dev/null
@@ -0,0 +1,13 @@
+
+# Listing of Parameters
+# ---------------------
+subsection Testing
+  # docs 3
+  set double      = 3.1415926
+  set int         = 3         # default: 1
+
+  # docs 1
+  set string list = a, b, c   # default: a
+end
+
+

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.