]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test
authorRene Gassmoeller <R.Gassmoeller@mailbox.org>
Fri, 4 Dec 2015 02:22:35 +0000 (20:22 -0600)
committerRene Gassmoeller <R.Gassmoeller@mailbox.org>
Thu, 10 Dec 2015 03:01:41 +0000 (21:01 -0600)
tests/base/utilities_11.cc [new file with mode: 0644]
tests/base/utilities_11.output [new file with mode: 0644]

diff --git a/tests/base/utilities_11.cc b/tests/base/utilities_11.cc
new file mode 100644 (file)
index 0000000..d201773
--- /dev/null
@@ -0,0 +1,71 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 2015 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.
+//
+// ---------------------------------------------------------------------
+
+
+// This tests the implementation of Utilities::to_string for different types.
+// Note that the floating point number output might be depend on the system.
+
+#include "../tests.h"
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+
+#include <deal.II/base/utilities.h>
+
+
+void test ()
+{
+  unsigned long long int i = std::pow(2,33);
+  deallog << Utilities::to_string(i) << std::endl;
+  deallog << Utilities::to_string(i,11) << std::endl;
+
+  unsigned long long j = std::pow(2,31);
+  deallog << Utilities::to_string (j) << std::endl;
+
+  int k = - std::pow(2,30);
+  deallog << Utilities::to_string (k) << std::endl;
+  deallog << Utilities::to_string (k,12) << std::endl;
+
+  long long int l = - std::pow(2,35);
+  deallog << Utilities::to_string (l) << std::endl;
+  deallog << Utilities::to_string (l,13) << std::endl;
+
+  float f (-3.14159265358979323846264338327950288419716939937510);
+  deallog << Utilities::to_string (f) << std::endl;
+  deallog << Utilities::to_string (f,13) << std::endl;
+
+  double d (-3.14159265358979323846264338327950288419716939937510);
+  deallog << Utilities::to_string (d) << std::endl;
+  deallog << Utilities::to_string (d,20) << std::endl;
+
+  long double ld (-3.14159265358979323846264338327950288419716939937510);
+  deallog << Utilities::to_string (ld) << std::endl;
+  deallog << Utilities::to_string (ld,24) << std::endl;
+
+
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/utilities_11.output b/tests/base/utilities_11.output
new file mode 100644 (file)
index 0000000..e98c81e
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::8589934592
+DEAL::08589934592
+DEAL::2147483648
+DEAL::-1073741824
+DEAL::-01073741824
+DEAL::-34359738368
+DEAL::-034359738368
+DEAL::-3.14159274
+DEAL::-003.14159274
+DEAL::-3.1415926535897931
+DEAL::-03.1415926535897931
+DEAL::-3.141592653589793116
+DEAL::-0003.141592653589793116

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.