From f4c4c88e6918081aeb2ac631cffeab7bdf718f88 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sat, 11 Jul 2015 17:40:28 -0400 Subject: [PATCH] test ParameterHandler::MultipleSelection --- tests/bits/parameter_handler_21.cc | 73 ++++++++++++++++++++++++++ tests/bits/parameter_handler_21.output | 13 +++++ 2 files changed, 86 insertions(+) create mode 100644 tests/bits/parameter_handler_21.cc create mode 100644 tests/bits/parameter_handler_21.output diff --git a/tests/bits/parameter_handler_21.cc b/tests/bits/parameter_handler_21.cc new file mode 100644 index 0000000000..3adef5e166 --- /dev/null +++ b/tests/bits/parameter_handler_21.cc @@ -0,0 +1,73 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2002 - 2014 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 the Patterns::MultipleSelection + +#include "../tests.h" +#include +#include +#include +#include + +void check (const char *defaults, const char* defined, const char *input) +{ + ParameterHandler prm; + prm.declare_entry ("v", defaults, Patterns::MultipleSelection(defined), ""); + + std::stringstream in(input); + prm.read_input (in); + + deallog << "defaults='" << defaults + << "' defined='" << defined + << "' input='" << input + << "' result='" << prm.get("v") << "'" << std::endl; +} + +void test() +{ + check("","one option","set v="); + check("one option","one option",""); + check("","one option","set v=one option"); + + check("","bla|bla 2|1",""); + check("","bla|bla 2|1","set v=bla 2"); + check("","bla|bla 2|1","set v=1,bla 2"); + check("","bla|bla 2|1","set v=bla,bla,bla"); + + check("default,alsodefault","default|nodefault|alsodefault",""); + check("default,alsodefault","default|nodefault|alsodefault","set v=nodefault"); + + check(" input 2 , have spaces ","have spaces|input 2",""); + + // check correct handling of space in input, default, and values: + check("input 2","have spaces|input 2","set v= input 2 , have spaces "); + + check("","double spaces|input 2","set v = double spaces , double spaces"); +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test(); + + return 0; +} diff --git a/tests/bits/parameter_handler_21.output b/tests/bits/parameter_handler_21.output new file mode 100644 index 0000000000..cd1140f675 --- /dev/null +++ b/tests/bits/parameter_handler_21.output @@ -0,0 +1,13 @@ + +DEAL::defaults='' defined='one option' input='set v=' result='' +DEAL::defaults='one option' defined='one option' input='' result='one option' +DEAL::defaults='' defined='one option' input='set v=one option' result='one option' +DEAL::defaults='' defined='bla|bla 2|1' input='' result='' +DEAL::defaults='' defined='bla|bla 2|1' input='set v=bla 2' result='bla 2' +DEAL::defaults='' defined='bla|bla 2|1' input='set v=1,bla 2' result='1,bla 2' +DEAL::defaults='' defined='bla|bla 2|1' input='set v=bla,bla,bla' result='bla,bla,bla' +DEAL::defaults='default,alsodefault' defined='default|nodefault|alsodefault' input='' result='default,alsodefault' +DEAL::defaults='default,alsodefault' defined='default|nodefault|alsodefault' input='set v=nodefault' result='nodefault' +DEAL::defaults=' input 2 , have spaces ' defined='have spaces|input 2' input='' result=' input 2 , have spaces ' +DEAL::defaults='input 2' defined='have spaces|input 2' input='set v= input 2 , have spaces ' result='input 2 , have spaces' +DEAL::defaults='' defined='double spaces|input 2' input='set v = double spaces , double spaces' result='' -- 2.39.5