From: Matthias Maier Date: Mon, 22 Jan 2024 22:17:59 +0000 (-0600) Subject: ParameterAcceptor: check that we set values correctly for multiple live objects of... X-Git-Tag: relicensing~117^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16521%2Fhead;p=dealii.git ParameterAcceptor: check that we set values correctly for multiple live objects of the same class Closes #16520 --- diff --git a/tests/parameter_handler/parameter_acceptor_12.cc b/tests/parameter_handler/parameter_acceptor_12.cc new file mode 100644 index 0000000000..d4af2c21e6 --- /dev/null +++ b/tests/parameter_handler/parameter_acceptor_12.cc @@ -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 + +#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 index 0000000000..36ee19b469 --- /dev/null +++ b/tests/parameter_handler/parameter_acceptor_12.output @@ -0,0 +1,3 @@ + +DEAL::1 - 1 - 1 +DEAL::2 - 2 - 2