]> https://gitweb.dealii.org/ - dealii.git/commitdiff
ParameterAcceptor: check that we set values correctly for multiple live objects of... 16521/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 22 Jan 2024 22:17:59 +0000 (16:17 -0600)
committerMatthias Maier <tamiko@43-1.org>
Mon, 22 Jan 2024 22:17:59 +0000 (16:17 -0600)
Closes #16520

tests/parameter_handler/parameter_acceptor_12.cc [new file with mode: 0644]
tests/parameter_handler/parameter_acceptor_12.output [new file with mode: 0644]

diff --git a/tests/parameter_handler/parameter_acceptor_12.cc b/tests/parameter_handler/parameter_acceptor_12.cc
new file mode 100644 (file)
index 0000000..d4af2c2
--- /dev/null
@@ -0,0 +1,52 @@
+//-----------------------------------------------------------
+//
+//    Copyright (C) 2023 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 that we set parameters for multiple instances of the same class
+// correctly
+
+#include <deal.II/base/parameter_acceptor.h>
+
+#include "../tests.h"
+
+struct Foo : public dealii::ParameterAcceptor
+{
+  Foo()
+    : dealii::ParameterAcceptor("A subsection")
+  {
+    add_parameter("A parameter", a);
+  }
+  int a = 1;
+};
+
+int
+main()
+{
+  initlog();
+
+  Foo foo_1;
+  Foo foo_2;
+  Foo foo_3;
+
+  deallog << foo_1.a << " - " << foo_2.a << " - " << foo_3.a << std::endl;
+
+  std::stringstream parameters;
+  parameters << "subsection A subsection\n"
+             << "set A parameter = 2\n"
+             << "end" << std::endl;
+  ParameterAcceptor::initialize(parameters);
+
+  deallog << foo_1.a << " - " << foo_2.a << " - " << foo_3.a << std::endl;
+}
diff --git a/tests/parameter_handler/parameter_acceptor_12.output b/tests/parameter_handler/parameter_acceptor_12.output
new file mode 100644 (file)
index 0000000..36ee19b
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::1 - 1 - 1
+DEAL::2 - 2 - 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.