From: Sebastian Proell Date: Sat, 19 Jun 2021 16:34:12 +0000 (+0200) Subject: Test custom separators for Patterns::Map X-Git-Tag: v9.4.0-rc1~966^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12788%2Fhead;p=dealii.git Test custom separators for Patterns::Map --- diff --git a/tests/parameter_handler/patterns_17.cc b/tests/parameter_handler/patterns_17.cc new file mode 100644 index 0000000000..22c713953f --- /dev/null +++ b/tests/parameter_handler/patterns_17.cc @@ -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 +#include +#include + +#include + +#include "../tests.h" + +using namespace Patterns::Tools; + +int +main() +{ + initlog(); + + std::map> 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 index 0000000000..66c47633f0 --- /dev/null +++ b/tests/parameter_handler/patterns_17.output @@ -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