]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Mar 2006 20:56:45 +0000 (20:56 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Mar 2006 20:56:45 +0000 (20:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@12600 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile
tests/base/is_finite.cc [new file with mode: 0644]
tests/base/is_finite/cmp/generic [new file with mode: 0644]

index 6e5363909c5b9a6ea2ef0fbd8ded8c39775f1680..08e4ce2698579db80e4fb8eb69a4fa7994d0972d 100644 (file)
@@ -40,7 +40,8 @@ tests_x =  logtest \
            hierarchical \
           data_out_base* \
           function_parser \
-          utilities_*
+          utilities_* \
+          is_finite
 
 # from above list of regular expressions, generate the real set of
 # tests
diff --git a/tests/base/is_finite.cc b/tests/base/is_finite.cc
new file mode 100644 (file)
index 0000000..aeee1a8
--- /dev/null
@@ -0,0 +1,69 @@
+//----------------------------  is_finite.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  is_finite.cc  ---------------------------
+
+// check deal_II_numbers::is_finite
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <typename T>
+void check ()
+{
+  using namespace deal_II_numbers;
+  
+  deallog << std::numeric_limits<T>::quiet_NaN() << "   -->   ";
+  deallog << is_finite(std::numeric_limits<T>::quiet_NaN()) << std::endl;
+
+  deallog << std::numeric_limits<T>::signaling_NaN() << "   -->   ";
+  deallog << is_finite(std::numeric_limits<T>::signaling_NaN()) << std::endl;
+
+  deallog << std::numeric_limits<T>::infinity() << "   -->   ";
+  deallog << is_finite(std::numeric_limits<T>::infinity()) << std::endl;
+
+  deallog << -std::numeric_limits<T>::infinity() << "   -->   ";
+  deallog << is_finite(-std::numeric_limits<T>::infinity()) << std::endl;
+
+  deallog << std::numeric_limits<T>::min() << "   -->   ";
+  deallog << is_finite(std::numeric_limits<T>::min()) << std::endl;
+
+  deallog << std::numeric_limits<T>::max() << "   -->   ";
+  deallog << is_finite(std::numeric_limits<T>::max()) << std::endl;
+
+  deallog << static_cast<T> (1) << "   -->   ";
+  deallog << is_finite(static_cast<T> (1)) << std::endl;
+
+  deallog << static_cast<T> (-1) << "   -->   ";
+  deallog << is_finite(static_cast<T> (-1)) << std::endl;
+}
+
+
+int main ()
+{
+  std::ofstream logfile("is_finite/output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check<double> ();
+  check<long double> ();
+
+  check<int> ();
+  check<unsigned int> ();
+  
+  return 0;
+}
+
diff --git a/tests/base/is_finite/cmp/generic b/tests/base/is_finite/cmp/generic
new file mode 100644 (file)
index 0000000..e287678
--- /dev/null
@@ -0,0 +1,33 @@
+
+DEAL::nan   -->   0
+DEAL::nan   -->   0
+DEAL::inf   -->   0
+DEAL::-inf   -->   0
+DEAL::0   -->   1
+DEAL::1.80e+308   -->   1
+DEAL::1.00   -->   1
+DEAL::-1.00   -->   1
+DEAL::nan   -->   0
+DEAL::nan   -->   0
+DEAL::inf   -->   0
+DEAL::-inf   -->   0
+DEAL::3.36e-4932   -->   1
+DEAL::1.19e+4932   -->   0
+DEAL::1.00   -->   1
+DEAL::-1.00   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::-2147483648   -->   1
+DEAL::2147483647   -->   1
+DEAL::1   -->   1
+DEAL::-1   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::0   -->   1
+DEAL::4294967295   -->   1
+DEAL::1   -->   1
+DEAL::4294967295   -->   1

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.