From: bangerth Date: Sat, 19 Jul 2014 12:44:08 +0000 (+0000) Subject: Detect errors in Utilities::string_to_int. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=827d231c52a8f4bb8e86f07a2a062803d1d617de;p=dealii-svn.git Detect errors in Utilities::string_to_int. git-svn-id: https://svn.dealii.org/trunk@33202 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/utilities_06.cc b/tests/base/utilities_06.cc new file mode 100644 index 0000000000..13163c830d --- /dev/null +++ b/tests/base/utilities_06.cc @@ -0,0 +1,64 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2005 - 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. +// +// --------------------------------------------------------------------- + + +// verify that Utilities::string_to_int actually catches errors + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + +using namespace dealii; + + + + +void verify (const std::string &s) +{ + bool exception_caught = false; + try + { + Utilities::string_to_int(s); + } + catch (...) + { + exception_caught = true; + } + Assert (exception_caught == true, ExcMessage ("Function is broken!")); + + deallog << "Done correctly: " << s << std::endl; +} + + + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + verify ("abc"); + verify ("1.23.4"); + verify ("1 23 4"); + verify ("123abc"); +} diff --git a/tests/base/utilities_06.output b/tests/base/utilities_06.output new file mode 100644 index 0000000000..110cf89fba --- /dev/null +++ b/tests/base/utilities_06.output @@ -0,0 +1,5 @@ + +DEAL::Done correctly: abc +DEAL::Done correctly: 1.23.4 +DEAL::Done correctly: 1 23 4 +DEAL::Done correctly: 123abc