From: bangerth Date: Fri, 8 Nov 2013 05:06:55 +0000 (+0000) Subject: Add a few tests. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee5ab3588a7cbd8f210114f48b4ff98b253d2053;p=dealii-svn.git Add a few tests. git-svn-id: https://svn.dealii.org/trunk@31583 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/parameter_handler_1_include.cc b/tests/bits/parameter_handler_1_include.cc new file mode 100644 index 0000000000..cc32b3e307 --- /dev/null +++ b/tests/bits/parameter_handler_1_include.cc @@ -0,0 +1,52 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2013 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 that we can do include statements + +#include "../tests.h" +#include +#include +#include + +void check (const char *p) +{ + ParameterHandler prm; + prm.declare_entry ("test_1", "-1,0", + Patterns::List(Patterns::Integer(-1,1),2,3)); + + std::ifstream in(p); + prm.read_input (in); + + deallog << "test_1=" << prm.get ("test_1") << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + // go into the source dir to read files there. this + // is necessary so that we can include files there + chdir (SOURCE_DIR); + check ("parameter_handler_1_include.prm"); + + return 0; +} diff --git a/tests/bits/parameter_handler_1_include.output b/tests/bits/parameter_handler_1_include.output new file mode 100644 index 0000000000..46f81e3b5e --- /dev/null +++ b/tests/bits/parameter_handler_1_include.output @@ -0,0 +1,2 @@ + +DEAL::test_1=1,0,1 diff --git a/tests/bits/parameter_handler_1_include.prm b/tests/bits/parameter_handler_1_include.prm new file mode 100644 index 0000000000..a2de6a5225 --- /dev/null +++ b/tests/bits/parameter_handler_1_include.prm @@ -0,0 +1,2 @@ +set test_1 = 1,1,1 +include parameter_handler_1_include.prm2 diff --git a/tests/bits/parameter_handler_1_include.prm2 b/tests/bits/parameter_handler_1_include.prm2 new file mode 100644 index 0000000000..cbf86bd5ac --- /dev/null +++ b/tests/bits/parameter_handler_1_include.prm2 @@ -0,0 +1,2 @@ +set test_1 = 1,0,1 + diff --git a/tests/bits/parameter_handler_1_include_fail.cc b/tests/bits/parameter_handler_1_include_fail.cc new file mode 100644 index 0000000000..7d6a205e4a --- /dev/null +++ b/tests/bits/parameter_handler_1_include_fail.cc @@ -0,0 +1,54 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2013 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 that we can do include statements. the current test verifies what +// happens if such an include statement fails + +#include "../tests.h" +#include +#include +#include + +void check (const char *p) +{ + ParameterHandler prm; + prm.declare_entry ("test_1", "-1,0", + Patterns::List(Patterns::Integer(-1,1),2,3)); + + std::ifstream in(p); + bool status = prm.read_input (in); + Assert (status == false, ExcInternalError()); + + deallog << "test_1=" << prm.get ("test_1") << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + // go into the source dir to read files there. this + // is necessary so that we can include files there + chdir (SOURCE_DIR); + check ("parameter_handler_1_include_fail.prm"); + + return 0; +} diff --git a/tests/bits/parameter_handler_1_include_fail.output b/tests/bits/parameter_handler_1_include_fail.output new file mode 100644 index 0000000000..433921bbe6 --- /dev/null +++ b/tests/bits/parameter_handler_1_include_fail.output @@ -0,0 +1,2 @@ + +DEAL::test_1=1,1,1 diff --git a/tests/bits/parameter_handler_1_include_fail.prm b/tests/bits/parameter_handler_1_include_fail.prm new file mode 100644 index 0000000000..e3ee532211 --- /dev/null +++ b/tests/bits/parameter_handler_1_include_fail.prm @@ -0,0 +1,4 @@ +set test_1 = 1,1,1 + +# the following file does not exist +include parameter_handler_1_include_fail.prm2