]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix Patterns::Tuple::description 5355/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 29 Oct 2017 10:14:19 +0000 (11:14 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 29 Oct 2017 21:39:59 +0000 (22:39 +0100)
include/deal.II/base/patterns.h
source/base/patterns.cc
tests/base/patterns_12.cc [new file with mode: 0644]
tests/base/patterns_12.output [new file with mode: 0644]

index d694d4e1b419faced6fd24c5ccc4c5b8afdac334..39abc223a6a2a111bdd057140649a487a5e2e837 100644 (file)
@@ -1271,6 +1271,8 @@ namespace Patterns
     static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
                   "Not all of the input arguments of this function "
                   "are derived from PatternBase");
+    static_assert(sizeof...(ps) > 0,
+                  "The number of PatternTypes must be greater than zero!");
     auto pattern_pointers = { (static_cast<const PatternBase *>(&ps))... };
     for (auto p : pattern_pointers)
       patterns.push_back (p->clone());
index 7c529584cc2685004e5a2f255b3c621c475d994c..7f069959989bcf7bae3bed0fece955285ab4badb 100644 (file)
@@ -1044,9 +1044,10 @@ namespace Patterns
             description << separator
                         << "[" << patterns[i]->description(style) << "]";
 
-            return description.str();
           }
+        return description.str();
       }
+
       default:
         AssertThrow(false, ExcNotImplemented());
       }
diff --git a/tests/base/patterns_12.cc b/tests/base/patterns_12.cc
new file mode 100644 (file)
index 0000000..e2d58f9
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 2015 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 that the description of a patterns works for all OutputStyles
+// and number of PatternStyles.
+
+#include "../tests.h"
+#include <deal.II/base/parameter_handler.h>
+#include <deal.II/base/std_cxx14/memory.h>
+#include <memory>
+
+int main()
+{
+  initlog();
+
+  // one pattern
+  {
+    const auto &pattern = Patterns::Tuple(Patterns::Double());
+
+    deallog << pattern.description(Patterns::PatternBase::OutputStyle::Machine) << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::Text)    << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::LaTeX)   << '\n'
+            << std::endl;
+  }
+
+  // two patterns
+  {
+    const auto &pattern = Patterns::Tuple(Patterns::Double(),
+                                          Patterns::Anything());
+
+    deallog << pattern.description(Patterns::PatternBase::OutputStyle::Machine) << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::Text)    << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::LaTeX)   << '\n'
+            << std::endl;
+  }
+
+  // three patterns
+  {
+    const auto &pattern = Patterns::Tuple(Patterns::Double(),
+                                          Patterns::Anything(),
+                                          Patterns::Bool());
+
+    deallog << pattern.description(Patterns::PatternBase::OutputStyle::Machine) << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::Text)    << '\n'
+            << pattern.description(Patterns::PatternBase::OutputStyle::LaTeX)   << '\n'
+            << std::endl;
+  }
+}
diff --git a/tests/base/patterns_12.output b/tests/base/patterns_12.output
new file mode 100644 (file)
index 0000000..defa863
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::[Tuple of <1> elements <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]>]
+A Tuple of 1 elements  where each element is [A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE]
+A Tuple of 1 elements  where each element is [A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$]
+
+DEAL::[Tuple of <2> elements <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]>, <[Anything]>]
+A Tuple of 2 elements  where each element is [A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE],[Any string]
+A Tuple of 2 elements  where each element is [A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$],[Any string]
+
+DEAL::[Tuple of <3> elements <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]>, <[Anything]>, <[Bool]>]
+A Tuple of 3 elements  where each element is [A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE],[Any string],[A boolean value (true or false)]
+A Tuple of 3 elements  where each element is [A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$],[Any string],[A boolean value (true or false)]
+

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.