From 11da511c784eca003deb90c23570f0873954e0de Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Sat, 18 Nov 2023 06:11:09 -0600 Subject: Initial commit. --- gmp-6.3.0/tests/cxx/t-ops2f.cc | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 gmp-6.3.0/tests/cxx/t-ops2f.cc (limited to 'gmp-6.3.0/tests/cxx/t-ops2f.cc') diff --git a/gmp-6.3.0/tests/cxx/t-ops2f.cc b/gmp-6.3.0/tests/cxx/t-ops2f.cc new file mode 100644 index 0000000..71c9e10 --- /dev/null +++ b/gmp-6.3.0/tests/cxx/t-ops2f.cc @@ -0,0 +1,87 @@ +/* Test mp*_class operators and functions. + +Copyright 2011, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 3 of the License, +or (at your option) any later version. + +The GNU MP Library test suite is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include "t-ops2.h" + +void checkf (){ + ASSERT_ALWAYS(sqrt(mpf_class(7))>2.64); + ASSERT_ALWAYS(sqrt(mpf_class(7))<2.65); + ASSERT_ALWAYS(sqrt(mpf_class(0))==0); + // TODO: add some consistency checks, as described in + // https://gmplib.org/list-archives/gmp-bugs/2013-February/002940.html + CHECK1(mpf_class,1.9,trunc); + CHECK1(mpf_class,1.9,floor); + CHECK1(mpf_class,1.9,ceil); + CHECK1(mpf_class,4.3,trunc); + CHECK1(mpf_class,4.3,floor); + CHECK1(mpf_class,4.3,ceil); + CHECK1(mpf_class,-7.1,trunc); + CHECK1(mpf_class,-7.1,floor); + CHECK1(mpf_class,-7.1,ceil); + CHECK1(mpf_class,-2.8,trunc); + CHECK1(mpf_class,-2.8,floor); + CHECK1(mpf_class,-2.8,ceil); + CHECK1(mpf_class,-1.5,trunc); + CHECK1(mpf_class,-1.5,floor); + CHECK1(mpf_class,-1.5,ceil); + CHECK1(mpf_class,2.5,trunc); + CHECK1(mpf_class,2.5,floor); + CHECK1(mpf_class,2.5,ceil); + ASSERT_ALWAYS(hypot(mpf_class(-3),mpf_class(4))>4.9); + ASSERT_ALWAYS(hypot(mpf_class(-3),mpf_class(4))<5.1); + ASSERT_ALWAYS(hypot(mpf_class(-3),4.)>4.9); + ASSERT_ALWAYS(hypot(-3.,mpf_class(4))<5.1); + ASSERT_ALWAYS(hypot(mpf_class(-3),4l)>4.9); + ASSERT_ALWAYS(hypot(-3l,mpf_class(4))<5.1); + ASSERT_ALWAYS(hypot(mpf_class(-3),4ul)>4.9); + ASSERT_ALWAYS(hypot(3ul,mpf_class(4))<5.1); + CHECK(mpf_class,mpq_class,1.5,2.25,+); + CHECK(mpf_class,mpq_class,1.5,2.25,-); + CHECK(mpf_class,mpq_class,1.5,-2.25,*); + CHECK(mpf_class,mpq_class,1.5,-2,/); + CHECK_MPQ(mpf_class,-5.5,-2.25,+); + CHECK_MPQ(mpf_class,-5.5,-2.25,-); + CHECK_MPQ(mpf_class,-5.5,-2.25,*); + CHECK_MPQ(mpf_class,-5.25,-0.5,/); + CHECK_MPQ(mpf_class,5,-2,<); + CHECK_MPQ(mpf_class,5,-2,>); + CHECK_MPQ(mpf_class,5,-2,<=); + CHECK_MPQ(mpf_class,5,-2,>=); + CHECK_MPQ(mpf_class,5,-2,==); + CHECK_MPQ(mpf_class,5,-2,!=); + CHECK_MPQ(mpf_class,0,0,<); + CHECK_MPQ(mpf_class,0,0,>); + CHECK_MPQ(mpf_class,0,0,<=); + CHECK_MPQ(mpf_class,0,0,>=); + CHECK_MPQ(mpf_class,0,0,==); + CHECK_MPQ(mpf_class,0,0,!=); +} + +int +main (void) +{ + tests_start(); + + // Enough precision for 1 + denorm_min + mpf_set_default_prec(DBL_MANT_DIG-DBL_MIN_EXP+42); + checkf(); + + tests_end(); + return 0; +} -- cgit v1.2.3