From 74f99778b90766af7d79e53bbad829414ac6dc43 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 15 Mar 2006 20:56:45 +0000 Subject: [PATCH] New test git-svn-id: https://svn.dealii.org/trunk@12600 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 3 +- tests/base/is_finite.cc | 69 ++++++++++++++++++++++++++++++++ tests/base/is_finite/cmp/generic | 33 +++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 tests/base/is_finite.cc create mode 100644 tests/base/is_finite/cmp/generic diff --git a/tests/base/Makefile b/tests/base/Makefile index 6e5363909c..08e4ce2698 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -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 index 0000000000..aeee1a8da1 --- /dev/null +++ b/tests/base/is_finite.cc @@ -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 +#include +#include + + +template +void check () +{ + using namespace deal_II_numbers; + + deallog << std::numeric_limits::quiet_NaN() << " --> "; + deallog << is_finite(std::numeric_limits::quiet_NaN()) << std::endl; + + deallog << std::numeric_limits::signaling_NaN() << " --> "; + deallog << is_finite(std::numeric_limits::signaling_NaN()) << std::endl; + + deallog << std::numeric_limits::infinity() << " --> "; + deallog << is_finite(std::numeric_limits::infinity()) << std::endl; + + deallog << -std::numeric_limits::infinity() << " --> "; + deallog << is_finite(-std::numeric_limits::infinity()) << std::endl; + + deallog << std::numeric_limits::min() << " --> "; + deallog << is_finite(std::numeric_limits::min()) << std::endl; + + deallog << std::numeric_limits::max() << " --> "; + deallog << is_finite(std::numeric_limits::max()) << std::endl; + + deallog << static_cast (1) << " --> "; + deallog << is_finite(static_cast (1)) << std::endl; + + deallog << static_cast (-1) << " --> "; + deallog << is_finite(static_cast (-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 (); + check (); + + check (); + check (); + + return 0; +} + diff --git a/tests/base/is_finite/cmp/generic b/tests/base/is_finite/cmp/generic new file mode 100644 index 0000000000..e287678092 --- /dev/null +++ b/tests/base/is_finite/cmp/generic @@ -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 -- 2.39.5