From b130d04eb1be13e84d0faabd121de8e578a9b5f9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 4 Nov 2007 05:45:08 +0000 Subject: [PATCH] Add tests for numbers::is_finite for complex arguments. git-svn-id: https://svn.dealii.org/trunk@15438 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 2 +- tests/base/is_finite_complex.cc | 75 ++++++++++++++++++++++++ tests/base/is_finite_complex/cmp/generic | 33 +++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 tests/base/is_finite_complex.cc create mode 100644 tests/base/is_finite_complex/cmp/generic diff --git a/tests/base/Makefile b/tests/base/Makefile index 8b6898977f..bc98bea5d9 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -51,7 +51,7 @@ tests_x = geometry_info_* \ functions_* \ function_parser \ utilities_* \ - is_finite \ + is_finite* \ number_traits_* ifeq ($(enable-multithreading),no) diff --git a/tests/base/is_finite_complex.cc b/tests/base/is_finite_complex.cc new file mode 100644 index 0000000000..2229b8294d --- /dev/null +++ b/tests/base/is_finite_complex.cc @@ -0,0 +1,75 @@ +//---------------------------- is_finite_complex.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2005, 2006, 2007 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_complex.cc --------------------------- + +// check numbers::is_finite for complex arguments + +#include "../tests.h" +#include +#include +#include +#include + + +template +void check () +{ + using namespace numbers; + + deallog << std::numeric_limits::real_type>::quiet_NaN() << " --> "; + deallog << is_finite(T(std::numeric_limits::real_type>::quiet_NaN(), 0)) << ' '; + deallog << is_finite(T(0,std::numeric_limits::real_type>::quiet_NaN())) << std::endl; + + deallog << std::numeric_limits::real_type>::signaling_NaN() << " --> "; + deallog << is_finite(T(std::numeric_limits::real_type>::signaling_NaN(), 0)) << ' '; + deallog << is_finite(T(0,std::numeric_limits::real_type>::signaling_NaN())) << std::endl; + + deallog << std::numeric_limits::real_type>::infinity() << " --> "; + deallog << is_finite(T(std::numeric_limits::real_type>::infinity(), 0)) << ' '; + deallog << is_finite(T(0, std::numeric_limits::real_type>::infinity())) << std::endl; + + deallog << -std::numeric_limits::real_type>::infinity() << " --> "; + deallog << is_finite(T(-std::numeric_limits::real_type>::infinity(), 0)) << ' '; + deallog << is_finite(T(0, -std::numeric_limits::real_type>::infinity())) << std::endl; + + deallog << std::numeric_limits::real_type>::min() << " --> "; + deallog << is_finite(T(std::numeric_limits::real_type>::min(), 0)) << ' '; + deallog << is_finite(T(0,std::numeric_limits::real_type>::min())) << std::endl; + + deallog << std::numeric_limits::real_type>::max() << " --> "; + deallog << is_finite(T(std::numeric_limits::real_type>::max(), 0)) << ' '; + deallog << is_finite(T(0, std::numeric_limits::real_type>::max())) << std::endl; + + deallog << static_cast::real_type> (1) << " --> "; + deallog << is_finite(T(static_cast::real_type> (1), 0)) << ' '; + deallog << is_finite(T(0, static_cast::real_type> (1))) << std::endl; + + deallog << static_cast::real_type> (-1) << " --> "; + deallog << is_finite(T(static_cast::real_type> (-1), 0)) << ' '; + deallog << is_finite(T(0, static_cast::real_type> (-1))) << std::endl; +} + + +int main () +{ + std::ofstream logfile("is_finite_complex/output"); + logfile.precision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check > (); + check > (); + + return 0; +} + diff --git a/tests/base/is_finite_complex/cmp/generic b/tests/base/is_finite_complex/cmp/generic new file mode 100644 index 0000000000..e287678092 --- /dev/null +++ b/tests/base/is_finite_complex/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