[Gmp-commit] /var/hg/gmp: Split t-ops2 which was getting too large.
mercurial at gmplib.org
mercurial at gmplib.org
Sun Nov 8 13:11:48 UTC 2015
details: /var/hg/gmp/rev/3703a5accf53
changeset: 16949:3703a5accf53
user: Marc Glisse <marc.glisse at inria.fr>
date: Sun Nov 08 14:11:46 2015 +0100
description:
Split t-ops2 which was getting too large.
diffstat:
ChangeLog | 5 +
tests/cxx/Makefile.am | 9 +-
tests/cxx/t-ops2.cc | 291 --------------------------------------------------
tests/cxx/t-ops2.h | 84 ++++++++++++++
tests/cxx/t-ops2f.cc | 87 ++++++++++++++
tests/cxx/t-ops2qf.cc | 85 ++++++++++++++
tests/cxx/t-ops2z.cc | 115 +++++++++++++++++++
7 files changed, 382 insertions(+), 294 deletions(-)
diffs (truncated from 725 to 300 lines):
diff -r a942ab0163d6 -r 3703a5accf53 ChangeLog
--- a/ChangeLog Sun Nov 08 13:11:38 2015 +0100
+++ b/ChangeLog Sun Nov 08 14:11:46 2015 +0100
@@ -21,6 +21,11 @@
* doc/gmp.texi: Document factorial and primorial.
* NEWS: Likewise.
+ * tests/cxx/t-ops2.cc: Remove and split into ...
+ * tests/cxx/t-ops2z.cc, tests/cxx/t-ops2qf.cc, tests/cxx/t-ops2f.cc,
+ tests/cxx/t-ops2.h: New files.
+ * tests/cxx/Makefile.am: Update for the split.
+
2015-11-07 Marc Glisse <marc.glisse at inria.fr>
* gmpxx.h (__GMP_DEFINE_UNARY_FUNCTION_1,
diff -r a942ab0163d6 -r 3703a5accf53 tests/cxx/Makefile.am
--- a/tests/cxx/Makefile.am Sun Nov 08 13:11:38 2015 +0100
+++ b/tests/cxx/Makefile.am Sun Nov 08 14:11:46 2015 +0100
@@ -34,10 +34,11 @@
if WANT_CXX
check_PROGRAMS = t-binary t-cast t-cxx11 \
t-headers t-iostream t-istream t-locale t-misc t-mix \
- t-ops t-ops3 t-ostream t-prec \
+ t-ops t-ops2qf t-ops2f t-ops3 t-ostream t-prec \
t-ternary t-unary \
t-do-exceptions-work-at-all-with-this-compiler \
- t-ops2 t-assign t-constr t-rand
+ t-ops2z t-assign t-constr t-rand
+EXTRA_DIST = t-ops2.h
TESTS = $(check_PROGRAMS)
endif
@@ -53,7 +54,9 @@
t_misc_SOURCES = t-misc.cc
t_mix_SOURCES = t-mix.cc
t_ops_SOURCES = t-ops.cc
-t_ops2_SOURCES = t-ops2.cc
+t_ops2z_SOURCES = t-ops2z.cc
+t_ops2qf_SOURCES = t-ops2qf.cc
+t_ops2f_SOURCES = t-ops2f.cc
t_ops3_SOURCES = t-ops3.cc
t_ostream_SOURCES = t-ostream.cc
t_prec_SOURCES = t-prec.cc
diff -r a942ab0163d6 -r 3703a5accf53 tests/cxx/t-ops2.cc
--- a/tests/cxx/t-ops2.cc Sun Nov 08 13:11:38 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-/* 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 "config.h"
-
-#include <math.h>
-
-#include "gmp.h"
-#include "gmpxx.h"
-#include "gmp-impl.h"
-#include "tests.h"
-
-
-#define CHECK1(Type,a,fun) \
- ASSERT_ALWAYS(fun((Type)(a))==fun(a))
-#define CHECK(Type1,Type2,a,b,op) \
- ASSERT_ALWAYS(((Type1)(a) op (Type2)(b))==((a) op (b)))
-#define CHECK_G(Type,a,b,op) \
- CHECK(Type,Type,a,b,op)
-#define CHECK_UI(Type,a,b,op) \
- CHECK(Type,unsigned long,a,b,op); \
- CHECK(unsigned long,Type,a,b,op)
-#define CHECK_SI(Type,a,b,op) \
- CHECK(Type,long,a,b,op); \
- CHECK(long,Type,a,b,op)
-#define CHECK_D(Type,a,b,op) \
- CHECK(Type,double,a,b,op); \
- CHECK(double,Type,a,b,op)
-#define CHECK_MPZ(Type,a,b,op) \
- CHECK(Type,mpz_class,a,b,op); \
- CHECK(mpz_class,Type,a,b,op)
-#define CHECK_MPQ(Type,a,b,op) \
- CHECK(Type,mpq_class,a,b,op); \
- CHECK(mpq_class,Type,a,b,op)
-#define CHECK_ALL_SIGNED(Type,a,b,op) \
- CHECK_G(Type,a,b,op); \
- CHECK_SI(Type,a,b,op); \
- CHECK_D(Type,a,b,op)
-#define CHECK_ALL_SIGNS(Type,a,b,op) \
- CHECK_ALL_SIGNED(Type,a,b,op); \
- CHECK_ALL_SIGNED(Type,-(a),b,op); \
- CHECK_ALL_SIGNED(Type,a,-(b),op); \
- CHECK_ALL_SIGNED(Type,-(a),-(b),op)
-#define CHECK_ALL(Type,a,b,op) \
- CHECK_ALL_SIGNED(Type,a,b,op); \
- CHECK_UI(Type,a,b,op)
-#define CHECK_ALL_SIGNED_COMPARISONS(Type,a,b) \
- CHECK_ALL_SIGNED(Type,a,b,<); \
- CHECK_ALL_SIGNED(Type,a,b,>); \
- CHECK_ALL_SIGNED(Type,a,b,<=); \
- CHECK_ALL_SIGNED(Type,a,b,>=); \
- CHECK_ALL_SIGNED(Type,a,b,==); \
- CHECK_ALL_SIGNED(Type,a,b,!=)
-#define CHECK_ALL_SIGNS_COMPARISONS(Type,a,b) \
- CHECK_ALL_SIGNS(Type,a,b,<); \
- CHECK_ALL_SIGNS(Type,a,b,>); \
- CHECK_ALL_SIGNS(Type,a,b,<=); \
- CHECK_ALL_SIGNS(Type,a,b,>=); \
- CHECK_ALL_SIGNS(Type,a,b,==); \
- CHECK_ALL_SIGNS(Type,a,b,!=)
-#define CHECK_ALL_COMPARISONS(Type,a,b) \
- CHECK_ALL(Type,a,b,<); \
- CHECK_ALL(Type,a,b,>); \
- CHECK_ALL(Type,a,b,<=); \
- CHECK_ALL(Type,a,b,>=); \
- CHECK_ALL(Type,a,b,==); \
- CHECK_ALL(Type,a,b,!=)
-
-
-void checkz (){
- CHECK_ALL(mpz_class,5,2,+);
- CHECK_ALL(mpz_class,5,2,-);
- CHECK_ALL(mpz_class,5,2,*);
- CHECK_ALL(mpz_class,5,2,/);
- CHECK_ALL(mpz_class,5,2,%);
- CHECK_ALL_COMPARISONS(mpz_class,5,2);
- CHECK_ALL_SIGNS(mpz_class,11,3,+);
- CHECK_ALL_SIGNS(mpz_class,11,3,-);
- CHECK_ALL_SIGNS(mpz_class,11,3,*);
- CHECK_ALL_SIGNS(mpz_class,11,3,/);
- CHECK_ALL_SIGNS(mpz_class,11,3,%);
- CHECK_ALL_SIGNS(mpz_class,17,2,*);
- CHECK_ALL_SIGNS(mpz_class,17,2,/);
- CHECK_ALL_SIGNS(mpz_class,17,2,%);
- CHECK(unsigned long,mpz_class,5,-2,/);
- CHECK(unsigned long,mpz_class,5,-2,%);
- ASSERT_ALWAYS(7ul/mpz_class(1e35)==0);
- ASSERT_ALWAYS(7ul%mpz_class(1e35)==7);
- ASSERT_ALWAYS(7ul/mpz_class(-1e35)==0);
- ASSERT_ALWAYS(7ul%mpz_class(-1e35)==7);
- CHECK_ALL_SIGNS_COMPARISONS(mpz_class,11,3);
- CHECK_ALL(mpz_class,6,3,&);
- CHECK_ALL(mpz_class,6,3,|);
- CHECK_ALL(mpz_class,6,3,^);
- CHECK(mpz_class,unsigned long,6,2,<<);
- CHECK(mpz_class,unsigned long,6,2,>>);
- CHECK(mpz_class,unsigned long,-13,2,<<);
- CHECK(mpz_class,unsigned long,-13,2,>>);
- ASSERT_ALWAYS(++mpz_class(7)==8);
- ASSERT_ALWAYS(++mpz_class(-8)==-7);
- ASSERT_ALWAYS(--mpz_class(8)==7);
- ASSERT_ALWAYS(--mpz_class(-7)==-8);
- ASSERT_ALWAYS(~mpz_class(7)==-8);
- ASSERT_ALWAYS(~mpz_class(-8)==7);
- ASSERT_ALWAYS(+mpz_class(7)==7);
- ASSERT_ALWAYS(+mpz_class(-8)==-8);
- ASSERT_ALWAYS(-mpz_class(7)==-7);
- ASSERT_ALWAYS(-mpz_class(-8)==8);
- ASSERT_ALWAYS(abs(mpz_class(7))==7);
- ASSERT_ALWAYS(abs(mpz_class(-8))==8);
- ASSERT_ALWAYS(sqrt(mpz_class(7))==2);
- ASSERT_ALWAYS(sqrt(mpz_class(0))==0);
- ASSERT_ALWAYS(sgn(mpz_class(0))==0);
- ASSERT_ALWAYS(sgn(mpz_class(9))==1);
- ASSERT_ALWAYS(sgn(mpz_class(-17))==-1);
- ASSERT_ALWAYS(mpz_class(1)+DBL_MAX>2);
- ASSERT_ALWAYS(mpz_class(1)+DBL_MIN<2);
- ASSERT_ALWAYS(mpz_class(1)+std::numeric_limits<double>::denorm_min()<2);
- ASSERT_ALWAYS(gcd(mpz_class(6),mpz_class(8))==2);
- ASSERT_ALWAYS(gcd(-mpz_class(6),mpz_class(8))==2);
- ASSERT_ALWAYS(gcd(-mpz_class(6),-mpz_class(8))==2);
- ASSERT_ALWAYS(gcd(mpz_class(6),8.f)==2);
- ASSERT_ALWAYS(gcd(-mpz_class(6),static_cast<unsigned char>(8))==2);
- ASSERT_ALWAYS(gcd(static_cast<long>(-6),mpz_class(5)+3)==2);
- ASSERT_ALWAYS(lcm(mpz_class(6),mpz_class(8))==24);
- ASSERT_ALWAYS(lcm(-mpz_class(6),mpz_class(8))==24);
- ASSERT_ALWAYS(lcm(-mpz_class(6),-mpz_class(8))==24);
- ASSERT_ALWAYS(lcm(mpz_class(6),static_cast<short>(8))==24);
- ASSERT_ALWAYS(lcm(-mpz_class(6),static_cast<unsigned char>(8))==24);
- ASSERT_ALWAYS(lcm(-6.,mpz_class(5)+3)==24);
- ASSERT_ALWAYS(factorial(mpz_class(3))==6);
- ASSERT_ALWAYS(factorial(mpz_class(5)-1)==24);
- ASSERT_ALWAYS(mpz_class::factorial(mpz_class(3))==6);
- ASSERT_ALWAYS(mpz_class::factorial(mpz_class(2)*2)==24);
- ASSERT_ALWAYS(mpz_class::factorial(3)==6);
- ASSERT_ALWAYS(mpz_class::factorial(3ul)==6);
- ASSERT_ALWAYS(mpz_class::factorial(3.f)==6);
- mpz_class ret;
- try { ret=factorial(-mpz_class(3)); ASSERT_ALWAYS(0); }
- catch (std::domain_error) {}
- try { ret=mpz_class::factorial(-2); ASSERT_ALWAYS(0); }
- catch (std::domain_error) {}
- try { ret=factorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); }
- catch (std::bad_alloc) {}
- ASSERT_ALWAYS(mpz_class::primorial(mpz_class(3))==6);
- ASSERT_ALWAYS(mpz_class::primorial(mpz_class(2)*2)==6);
- ASSERT_ALWAYS(mpz_class::primorial(3)==6);
- ASSERT_ALWAYS(mpz_class::primorial(3ul)==6);
- ASSERT_ALWAYS(mpz_class::primorial(3.f)==6);
- ASSERT_ALWAYS(mpz_class::primorial(-mpz_class(3))==1);
- ASSERT_ALWAYS(mpz_class::primorial(-5)==1);
- try { ret=primorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); }
- catch (std::bad_alloc) {}
-}
-
-template<class T>
-void checkqf (){
- CHECK_ALL(T,5.,2,+); CHECK_MPZ(T,5.,2,+);
- CHECK_ALL(T,5.,2,-); CHECK_MPZ(T,5.,2,-);
- CHECK_ALL(T,5.,2,*); CHECK_MPZ(T,5.,2,*);
- CHECK_ALL(T,5.,2,/); CHECK_MPZ(T,5.,2,/);
- CHECK_ALL(T,0.,2,/);
- CHECK_ALL_SIGNS(T,11.,3,+);
- CHECK_ALL_SIGNS(T,11.,3,-);
- CHECK_ALL_SIGNS(T,11.,3,*);
- CHECK_ALL_SIGNS(T,11.,4,/);
- CHECK_SI(T,LONG_MIN,1,*);
- CHECK_SI(T,0,3,*);
- CHECK_ALL_COMPARISONS(T,5.,2);
- CHECK_ALL_SIGNS_COMPARISONS(T,11.,3);
- CHECK_MPZ(T,5,-2,<);
- CHECK_MPZ(T,5,-2,>);
- CHECK_MPZ(T,5,-2,<=);
- CHECK_MPZ(T,5,-2,>=);
- CHECK_MPZ(T,5,-2,==);
- CHECK_MPZ(T,5,-2,!=);
- CHECK_MPZ(T,0,0,<);
- CHECK_MPZ(T,0,0,>);
- CHECK_MPZ(T,0,0,<=);
- CHECK_MPZ(T,0,0,>=);
- CHECK_MPZ(T,0,0,==);
- CHECK_MPZ(T,0,0,!=);
- ASSERT_ALWAYS(T(6)<<2==6.*4);
- ASSERT_ALWAYS(T(6)>>2==6./4);
- ASSERT_ALWAYS(T(-13)<<2==-13.*4);
- ASSERT_ALWAYS(T(-13)>>2==-13./4);
- ASSERT_ALWAYS(++T(7)==8);
- ASSERT_ALWAYS(++T(-8)==-7);
- ASSERT_ALWAYS(--T(8)==7);
- ASSERT_ALWAYS(--T(-7)==-8);
- ASSERT_ALWAYS(+T(7)==7);
- ASSERT_ALWAYS(+T(-8)==-8);
- ASSERT_ALWAYS(-T(7)==-7);
- ASSERT_ALWAYS(-T(-8)==8);
- ASSERT_ALWAYS(abs(T(7))==7);
- ASSERT_ALWAYS(abs(T(-8))==8);
- ASSERT_ALWAYS(sgn(T(0))==0);
- ASSERT_ALWAYS(sgn(T(9))==1);
- ASSERT_ALWAYS(sgn(T(-17))==-1);
- ASSERT_ALWAYS(T(1)+DBL_MAX>2);
- ASSERT_ALWAYS(T(1)+DBL_MIN>1);
- ASSERT_ALWAYS(T(1)+DBL_MIN<1.001);
- ASSERT_ALWAYS(T(1)+std::numeric_limits<double>::denorm_min()>1);
- ASSERT_ALWAYS(T(1)+std::numeric_limits<double>::denorm_min()<1.001);
-}
-
-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);
More information about the gmp-commit
mailing list