]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test custom separators for Patterns::Map 12788/head
authorSebastian Proell <proell@lnm.mw.tum.de>
Sat, 19 Jun 2021 16:34:12 +0000 (18:34 +0200)
committerSebastian Proell <sebastian.proell@tum.de>
Mon, 4 Oct 2021 12:01:27 +0000 (14:01 +0200)
tests/parameter_handler/patterns_17.cc [new file with mode: 0644]
tests/parameter_handler/patterns_17.output [new file with mode: 0644]

diff --git a/tests/parameter_handler/patterns_17.cc b/tests/parameter_handler/patterns_17.cc
new file mode 100644 (file)
index 0000000..22c7139
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 2020 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// test a map with pair with default and custom pattern
+#include <deal.II/base/parameter_handler.h>
+#include <deal.II/base/patterns.h>
+#include <deal.II/base/point.h>
+
+#include <memory>
+
+#include "../tests.h"
+
+using namespace Patterns::Tools;
+
+int
+main()
+{
+  initlog();
+
+  std::map<unsigned int, std::pair<int, int>> a;
+  a[3] = std::make_pair(1, 2);
+  a[2] = std::make_pair(3, 4);
+
+  auto b = a;
+  auto c = a;
+
+  ParameterHandler prm;
+  prm.add_parameter("A map using the default pattern", a);
+
+
+  prm.add_parameter("A map with explicitly stated default separators",
+                    b,
+                    "",
+                    Patterns::Map(Patterns::Integer(0),
+                                  Patterns::Tuple(":",
+                                                  Patterns::Integer(),
+                                                  Patterns::Integer()),
+                                  0,
+                                  Patterns::Map::max_int_value,
+                                  ",",
+                                  "="));
+
+  Patterns::Map custom_pattern(Patterns::Integer(0),
+                               Patterns::Tuple(",",
+                                               Patterns::Integer(),
+                                               Patterns::Integer()),
+                               0,
+                               Patterns::Map::max_int_value,
+                               ";",
+                               ":");
+
+  prm.add_parameter("A map with custom separators", c, "", custom_pattern);
+
+  prm.log_parameters(deallog);
+
+  return 0;
+}
diff --git a/tests/parameter_handler/patterns_17.output b/tests/parameter_handler/patterns_17.output
new file mode 100644 (file)
index 0000000..66c4763
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL:parameters::A map using the default pattern: 2=3 : 4, 3=1 : 2
+DEAL:parameters::A map with custom separators: 2:3 , 4; 3:1 , 2
+DEAL:parameters::A map with explicitly stated default separators: 2=3 : 4, 3=1 : 2

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.