]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Detect errors in Utilities::string_to_int.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 19 Jul 2014 12:44:08 +0000 (12:44 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Sun, 20 Jul 2014 22:16:58 +0000 (00:16 +0200)
git-svn-id: https://svn.dealii.org/trunk@33202 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/utilities_06.cc [new file with mode: 0644]
tests/base/utilities_06.output [new file with mode: 0644]

diff --git a/tests/base/utilities_06.cc b/tests/base/utilities_06.cc
new file mode 100644 (file)
index 0000000..13163c8
--- /dev/null
@@ -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 <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <sstream>
+
+#include <deal.II/base/utilities.h>
+
+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 (file)
index 0000000..110cf89
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Done correctly: abc
+DEAL::Done correctly: 1.23.4
+DEAL::Done correctly: 1 23 4
+DEAL::Done correctly: 123abc

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.