diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-01-06 21:49:16 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-01-06 21:49:16 +0100 |
commit | 5a1b0c90b5959886ffd1b06aa2eb6005a14d3c5a (patch) | |
tree | ba33722801f5389d9097cb1f0c629031ffa75555 /tests/mpq | |
parent | e50a2626904ed32eaba3134d3f0c92c55b2a04fe (diff) | |
download | gmp-5a1b0c90b5959886ffd1b06aa2eb6005a14d3c5a.tar.gz |
* mpz/tests, mpq/tests, mpf/tests, mpbsd/tests: Move directories to
tests/mpz etc.
Diffstat (limited to 'tests/mpq')
-rw-r--r-- | tests/mpq/Makefile.am | 29 | ||||
-rw-r--r-- | tests/mpq/Makefile.in | 456 | ||||
-rw-r--r-- | tests/mpq/t-cmp.c | 101 | ||||
-rw-r--r-- | tests/mpq/t-cmp_ui.c | 104 | ||||
-rw-r--r-- | tests/mpq/t-get_d.c | 120 | ||||
-rw-r--r-- | tests/mpq/t-md_2exp.c | 176 | ||||
-rw-r--r-- | tests/mpq/t-set_f.c | 160 |
7 files changed, 1146 insertions, 0 deletions
diff --git a/tests/mpq/Makefile.am b/tests/mpq/Makefile.am new file mode 100644 index 000000000..1b02161bb --- /dev/null +++ b/tests/mpq/Makefile.am @@ -0,0 +1,29 @@ +## Process this file with automake to generate Makefile.in + +# Copyright 1996, 1999, 2000 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library. +# +# The GNU MP Library is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at your +# option) any later version. +# +# The GNU MP Library 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 Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with the GNU MP Library; see the file COPYING.LIB. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + + +AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr + +INCLUDES = -I$(top_srcdir) +LDADD = $(top_builddir)/libgmp.la + +check_PROGRAMS = t-cmp t-cmp_ui t-get_d t-md_2exp t-set_f +TESTS = $(check_PROGRAMS) diff --git a/tests/mpq/Makefile.in b/tests/mpq/Makefile.in new file mode 100644 index 000000000..0d2d28661 --- /dev/null +++ b/tests/mpq/Makefile.in @@ -0,0 +1,456 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : + +@SET_MAKE@ +host_alias = @host_alias@ +host_triplet = @host@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@ +CC = @CC@ +CCAS = @CCAS@ +CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +GMP_LDFLAGS = @GMP_LDFLAGS@ +LIBM = @LIBM@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +M4 = @M4@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@ +STRIP = @STRIP@ +TUNE_SQR_OBJ = @TUNE_SQR_OBJ@ +U = @U@ +VERSION = @VERSION@ +gmp_srclinks = @gmp_srclinks@ +install_sh = @install_sh@ +mpn_objects = @mpn_objects@ +mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ + +# Copyright 1996, 1999, 2000 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library. +# +# The GNU MP Library is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at your +# option) any later version. +# +# The GNU MP Library 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 Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with the GNU MP Library; see the file COPYING.LIB. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + + +AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr + +INCLUDES = -I$(top_srcdir) +LDADD = $(top_builddir)/libgmp.la + +check_PROGRAMS = t-cmp t-cmp_ui t-get_d t-md_2exp t-set_f +TESTS = $(check_PROGRAMS) +subdir = mpq/tests +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +check_PROGRAMS = t-cmp$(EXEEXT) t-cmp_ui$(EXEEXT) t-get_d$(EXEEXT) \ +t-md_2exp$(EXEEXT) t-set_f$(EXEEXT) + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +ANSI2KNR = $(top_builddir)/ansi2knr +t_cmp_SOURCES = t-cmp.c +t_cmp_OBJECTS = t-cmp$U.$(OBJEXT) +t_cmp_LDADD = $(LDADD) +t_cmp_DEPENDENCIES = $(top_builddir)/libgmp.la +t_cmp_LDFLAGS = +t_cmp_ui_SOURCES = t-cmp_ui.c +t_cmp_ui_OBJECTS = t-cmp_ui$U.$(OBJEXT) +t_cmp_ui_LDADD = $(LDADD) +t_cmp_ui_DEPENDENCIES = $(top_builddir)/libgmp.la +t_cmp_ui_LDFLAGS = +t_get_d_SOURCES = t-get_d.c +t_get_d_OBJECTS = t-get_d$U.$(OBJEXT) +t_get_d_LDADD = $(LDADD) +t_get_d_DEPENDENCIES = $(top_builddir)/libgmp.la +t_get_d_LDFLAGS = +t_md_2exp_SOURCES = t-md_2exp.c +t_md_2exp_OBJECTS = t-md_2exp$U.$(OBJEXT) +t_md_2exp_LDADD = $(LDADD) +t_md_2exp_DEPENDENCIES = $(top_builddir)/libgmp.la +t_md_2exp_LDFLAGS = +t_set_f_SOURCES = t-set_f.c +t_set_f_OBJECTS = t-set_f$U.$(OBJEXT) +t_set_f_LDADD = $(LDADD) +t_set_f_DEPENDENCIES = $(top_builddir)/libgmp.la +t_set_f_LDFLAGS = +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CFLAGS = @CFLAGS@ +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = t-cmp.c t-cmp_ui.c t-get_d.c t-md_2exp.c t-set_f.c +depcomp = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +GZIP_ENV = --best +SOURCES = t-cmp.c t-cmp_ui.c t-get_d.c t-md_2exp.c t-set_f.c +OBJECTS = t-cmp$U.$(OBJEXT) t-cmp_ui$U.$(OBJEXT) t-get_d$U.$(OBJEXT) t-md_2exp$U.$(OBJEXT) t-set_f$U.$(OBJEXT) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu mpq/tests/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-checkPROGRAMS: + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +distclean-checkPROGRAMS: + +maintainer-clean-checkPROGRAMS: + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: +$(top_builddir)/ansi2knr: $(top_builddir)/ansi2knr.$(OBJEXT) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr + +$(top_builddir)/ansi2knr.$(OBJEXT): + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr.$(OBJEXT) + + +mostlyclean-kr: + -rm -f *_.c + +clean-kr: + +distclean-kr: + +maintainer-clean-kr: + +t-cmp$(EXEEXT): $(t_cmp_OBJECTS) $(t_cmp_DEPENDENCIES) + @rm -f t-cmp$(EXEEXT) + $(LINK) $(t_cmp_LDFLAGS) $(t_cmp_OBJECTS) $(t_cmp_LDADD) $(LIBS) + +t-cmp_ui$(EXEEXT): $(t_cmp_ui_OBJECTS) $(t_cmp_ui_DEPENDENCIES) + @rm -f t-cmp_ui$(EXEEXT) + $(LINK) $(t_cmp_ui_LDFLAGS) $(t_cmp_ui_OBJECTS) $(t_cmp_ui_LDADD) $(LIBS) + +t-get_d$(EXEEXT): $(t_get_d_OBJECTS) $(t_get_d_DEPENDENCIES) + @rm -f t-get_d$(EXEEXT) + $(LINK) $(t_get_d_LDFLAGS) $(t_get_d_OBJECTS) $(t_get_d_LDADD) $(LIBS) + +t-md_2exp$(EXEEXT): $(t_md_2exp_OBJECTS) $(t_md_2exp_DEPENDENCIES) + @rm -f t-md_2exp$(EXEEXT) + $(LINK) $(t_md_2exp_LDFLAGS) $(t_md_2exp_OBJECTS) $(t_md_2exp_LDADD) $(LIBS) + +t-set_f$(EXEEXT): $(t_set_f_OBJECTS) $(t_set_f_DEPENDENCIES) + @rm -f t-set_f$(EXEEXT) + $(LINK) $(t_set_f_LDFLAGS) $(t_set_f_OBJECTS) $(t_set_f_LDADD) $(LIBS) +.c.o: + $(COMPILE) -c $< +.c.obj: + $(COMPILE) -c `cygpath -w $<` +.c.lo: + $(LTCOMPILE) -c -o $@ $< +t-cmp_.c: t-cmp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-cmp.c; then echo $(srcdir)/t-cmp.c; else echo t-cmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-cmp_.c +t-cmp_ui_.c: t-cmp_ui.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-cmp_ui.c; then echo $(srcdir)/t-cmp_ui.c; else echo t-cmp_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-cmp_ui_.c +t-get_d_.c: t-get_d.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-get_d.c; then echo $(srcdir)/t-get_d.c; else echo t-get_d.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-get_d_.c +t-md_2exp_.c: t-md_2exp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-md_2exp.c; then echo $(srcdir)/t-md_2exp.c; else echo t-md_2exp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-md_2exp_.c +t-set_f_.c: t-set_f.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-set_f.c; then echo $(srcdir)/t-set_f.c; else echo t-set_f.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-set_f_.c +t-cmp_.$(OBJEXT) t-cmp_.lo t-cmp_ui_.$(OBJEXT) t-cmp_ui_.lo \ +t-get_d_.$(OBJEXT) t-get_d_.lo t-md_2exp_.$(OBJEXT) t-md_2exp_.lo \ +t-set_f_.$(OBJEXT) t-set_f_.lo : $(ANSI2KNR) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + -rm -f Makefile.in +mostlyclean-am: mostlyclean-checkPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-kr mostlyclean-tags \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-checkPROGRAMS clean-compile clean-libtool clean-kr \ + clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-checkPROGRAMS distclean-compile \ + distclean-libtool distclean-kr distclean-tags \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-checkPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-kr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-checkPROGRAMS distclean-checkPROGRAMS \ +clean-checkPROGRAMS maintainer-clean-checkPROGRAMS mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool mostlyclean-kr distclean-kr clean-kr \ +maintainer-clean-kr tags mostlyclean-tags distclean-tags clean-tags \ +maintainer-clean-tags check-TESTS distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all install-strip installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tests/mpq/t-cmp.c b/tests/mpq/t-cmp.c new file mode 100644 index 000000000..dd29f1705 --- /dev/null +++ b/tests/mpq/t-cmp.c @@ -0,0 +1,101 @@ +/* Test mpq_cmp. + +Copyright 1996, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> + +#include "gmp.h" +#include "gmp-impl.h" +#include "urandom.h" + +#define NUM(x) (&((x)->_mp_num)) +#define DEN(x) (&((x)->_mp_den)) + +#define SGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0) + +int +ref_mpq_cmp (mpq_t a, mpq_t b) +{ + mpz_t ai, bi; + int cc; + + mpz_init (ai); + mpz_init (bi); + + mpz_mul (ai, NUM (a), DEN (b)); + mpz_mul (bi, NUM (b), DEN (a)); + cc = mpz_cmp (ai, bi); + mpz_clear (ai); + mpz_clear (bi); + return cc; +} + +#ifndef SIZE +#define SIZE 8 /* increasing this lowers the probabilty of finding an error */ +#endif + +main (int argc, char **argv) +{ + mpq_t a, b; + mp_size_t size; + int reps = 100000; + int i; + int cc, ccref; + + if (argc == 2) + reps = atoi (argv[1]); + + mpq_init (a); + mpq_init (b); + + for (i = 0; i < reps; i++) + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (NUM (a), size); + do + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (DEN (a), size); + } + while (mpz_cmp_ui (DEN (a), 0) == 0); + + size = urandom () % SIZE - SIZE/2; + mpz_random2 (NUM (b), size); + do + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (DEN (b), size); + } + while (mpz_cmp_ui (DEN (b), 0) == 0); + + mpq_canonicalize (a); + mpq_canonicalize (b); + + ccref = ref_mpq_cmp (a, b); + cc = mpq_cmp (a, b); + + if (SGN (ccref) != SGN (cc)) + abort (); + } + + exit (0); +} diff --git a/tests/mpq/t-cmp_ui.c b/tests/mpq/t-cmp_ui.c new file mode 100644 index 000000000..8b47b5865 --- /dev/null +++ b/tests/mpq/t-cmp_ui.c @@ -0,0 +1,104 @@ +/* Test mpq_cmp_ui. + +Copyright 1996, 1997, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> + +#include "gmp.h" +#include "gmp-impl.h" +#include "urandom.h" + +#define NUM(x) (&((x)->_mp_num)) +#define DEN(x) (&((x)->_mp_den)) + +#define SGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0) + +int +ref_mpq_cmp_ui (mpq_t a, unsigned long int bn, unsigned long int bd) +{ + mpz_t ai, bi; + int cc; + + mpz_init (ai); + mpz_init (bi); + + mpz_mul_ui (ai, NUM (a), bd); + mpz_mul_ui (bi, DEN (a), bn); + cc = mpz_cmp (ai, bi); + mpz_clear (ai); + mpz_clear (bi); + return cc; +} + +#ifndef SIZE +#define SIZE 8 /* increasing this lowers the probabilty of finding an error */ +#endif + +main (int argc, char **argv) +{ + mpq_t a, b; + mp_size_t size; + int reps = 100000; + int i; + int cc, ccref; + unsigned long int bn, bd; + + if (argc == 2) + reps = atoi (argv[1]); + + mpq_init (a); + mpq_init (b); + + for (i = 0; i < reps; i++) + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (NUM (a), size); + do + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (DEN (a), size); + } + while (mpz_cmp_ui (DEN (a), 0) == 0); + + mpz_random2 (NUM (b), 1); + mpz_mod_ui (NUM (b), NUM (b), ~(unsigned long int) 0); + mpz_add_ui (NUM (b), NUM (b), 1); + + mpz_random2 (DEN (b), 1); + mpz_mod_ui (DEN (b), DEN (b), ~(unsigned long int) 0); + mpz_add_ui (DEN (b), DEN (b), 1); + + mpq_canonicalize (a); + mpq_canonicalize (b); + + bn = mpz_get_ui (NUM (b)); + bd = mpz_get_ui (DEN (b)); + + ccref = ref_mpq_cmp_ui (a, bn, bd); + cc = mpq_cmp_ui (a, bn, bd); + + if (SGN (ccref) != SGN (cc)) + abort (); + } + + exit (0); +} diff --git a/tests/mpq/t-get_d.c b/tests/mpq/t-get_d.c new file mode 100644 index 000000000..f182077bb --- /dev/null +++ b/tests/mpq/t-get_d.c @@ -0,0 +1,120 @@ +/* Test mpq_get_d and mpq_set_d + +Copyright 1991, 1993, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> + +#include "gmp.h" +#include "gmp-impl.h" +#include "urandom.h" + +#ifndef SIZE +#define SIZE 8 +#endif + +#if defined (__vax__) && SIZE > 4 +#undef SIZE +#define SIZE 4 +#endif + +void dump _PROTO ((mpq_t)); + +main (int argc, char **argv) +{ + mpq_t a; + mp_size_t size; + int reps = 1000; + int i, j; + double last_d, new_d; + mpq_t qlast_d, qnew_d; + mpq_t eps; + + if (argc == 2) + reps = atoi (argv[1]); + + /* The idea here is to test the monotonousness of mpq_get_d by adding + numbers to the numerator and denominator. */ + + mpq_init (a); + mpq_init (eps); + mpq_init (qlast_d); + mpq_init (qnew_d); + + for (i = 0; i < reps; i++) + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (mpq_numref (a), size); + do + { + size = urandom () % SIZE - SIZE/2; + mpz_random2 (mpq_denref (a), size); + } + while (mpz_cmp_ui (mpq_denref (a), 0) == 0); + + mpq_canonicalize (a); + + last_d = mpq_get_d (a); + mpq_set_d (qlast_d, last_d); + for (j = 0; j < 10; j++) + { + size = urandom () % SIZE + 1; + mpz_random2 (mpq_numref (eps), size); + size = urandom () % SIZE + 1; + mpz_random2 (mpq_denref (eps), size); + mpq_canonicalize (eps); + + mpq_add (a, a, eps); + mpq_canonicalize (a); + new_d = mpq_get_d (a); + if (last_d > new_d) + { + fprintf (stderr, "ERROR (test %d/%d): bad mpq_get_d results\n", i, j); + printf ("\nlast: %f\n ", last_d); + printf (" new: %f\n ", new_d); dump (a); + abort (); + } + mpq_set_d (qnew_d, new_d); + MPQ_CHECK_FORMAT (qnew_d); + if (mpq_cmp (qlast_d, qnew_d) > 0) + { + fprintf (stderr, + "ERROR (test %d/%d): bad mpq_set_d results\n", i, j); + printf ("\nlast: %f\n ", last_d); dump (qlast_d); + printf (" new: %f\n ", new_d); dump (qnew_d); + abort (); + } + last_d = new_d; + mpq_set (qlast_d, qnew_d); + } + } + + exit (0); +} + +void +dump (mpq_t x) +{ + mpz_out_str (stdout, 10, mpq_numref (x)); + printf ("/"); + mpz_out_str (stdout, 10, mpq_denref (x)); + printf ("\n"); +} diff --git a/tests/mpq/t-md_2exp.c b/tests/mpq/t-md_2exp.c new file mode 100644 index 000000000..77aaada2a --- /dev/null +++ b/tests/mpq/t-md_2exp.c @@ -0,0 +1,176 @@ +/* Test mpq_mul_2exp and mpq_div_2exp. + +Copyright 2000 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp.h" +#include "gmp-impl.h" + + +struct pair_t { + const char *num; + const char *den; +}; + +int +main (void) +{ + struct { + struct pair_t left; + unsigned long n; + struct pair_t right; + + } data[] = { + { {"0","1"}, 0, {"0","1"} }, + { {"0","1"}, 1, {"0","1"} }, + { {"0","1"}, 2, {"0","1"} }, + + { {"1","1"}, 0, {"1","1"} }, + { {"1","1"}, 1, {"2","1"} }, + { {"1","1"}, 2, {"4","1"} }, + { {"1","1"}, 3, {"8","1"} }, + + { {"1","1"}, 31, {"0x80000000","1"} }, + { {"1","1"}, 32, {"0x100000000","1"} }, + { {"1","1"}, 33, {"0x200000000","1"} }, + { {"1","1"}, 63, {"0x8000000000000000","1"} }, + { {"1","1"}, 64, {"0x10000000000000000","1"} }, + { {"1","1"}, 65, {"0x20000000000000000","1"} }, + { {"1","1"}, 95, {"0x800000000000000000000000","1"} }, + { {"1","1"}, 96, {"0x1000000000000000000000000","1"} }, + { {"1","1"}, 97, {"0x2000000000000000000000000","1"} }, + { {"1","1"}, 127, {"0x80000000000000000000000000000000","1"} }, + { {"1","1"}, 128, {"0x100000000000000000000000000000000","1"} }, + { {"1","1"}, 129, {"0x200000000000000000000000000000000","1"} }, + + { {"1","2"}, 31, {"0x40000000","1"} }, + { {"1","2"}, 32, {"0x80000000","1"} }, + { {"1","2"}, 33, {"0x100000000","1"} }, + { {"1","2"}, 63, {"0x4000000000000000","1"} }, + { {"1","2"}, 64, {"0x8000000000000000","1"} }, + { {"1","2"}, 65, {"0x10000000000000000","1"} }, + { {"1","2"}, 95, {"0x400000000000000000000000","1"} }, + { {"1","2"}, 96, {"0x800000000000000000000000","1"} }, + { {"1","2"}, 97, {"0x1000000000000000000000000","1"} }, + { {"1","2"}, 127, {"0x40000000000000000000000000000000","1"} }, + { {"1","2"}, 128, {"0x80000000000000000000000000000000","1"} }, + { {"1","2"}, 129, {"0x100000000000000000000000000000000","1"} }, + + { {"1","0x80000000"}, 30, {"1","2"} }, + { {"1","0x80000000"}, 31, {"1","1"} }, + { {"1","0x80000000"}, 32, {"2","1"} }, + { {"1","0x80000000"}, 33, {"4","1"} }, + { {"1","0x80000000"}, 62, {"0x80000000","1"} }, + { {"1","0x80000000"}, 63, {"0x100000000","1"} }, + { {"1","0x80000000"}, 64, {"0x200000000","1"} }, + { {"1","0x80000000"}, 94, {"0x8000000000000000","1"} }, + { {"1","0x80000000"}, 95, {"0x10000000000000000","1"} }, + { {"1","0x80000000"}, 96, {"0x20000000000000000","1"} }, + { {"1","0x80000000"}, 126, {"0x800000000000000000000000","1"} }, + { {"1","0x80000000"}, 127, {"0x1000000000000000000000000","1"} }, + { {"1","0x80000000"}, 128, {"0x2000000000000000000000000","1"} }, + + { {"1","0x100000000"}, 1, {"1","0x80000000"} }, + { {"1","0x100000000"}, 2, {"1","0x40000000"} }, + { {"1","0x100000000"}, 3, {"1","0x20000000"} }, + + { {"1","0x10000000000000000"}, 1, {"1","0x8000000000000000"} }, + { {"1","0x10000000000000000"}, 2, {"1","0x4000000000000000"} }, + { {"1","0x10000000000000000"}, 3, {"1","0x2000000000000000"} }, + }; + + void (*fun) _PROTO ((mpq_ptr, mpq_srcptr, unsigned long)); + const struct pair_t *p_start, *p_want; + const char *name; + mpq_t sep, got, want; + mpq_ptr q; + int i, muldiv, sign, overlap; + + mpq_init (sep); + mpq_init (got); + mpq_init (want); + + for (i = 0; i < numberof (data); i++) + { + for (muldiv = 0; muldiv < 2; muldiv++) + { + if (muldiv == 0) + { + fun = mpq_mul_2exp; + name = "mpq_mul_2exp"; + p_start = &data[i].left; + p_want = &data[i].right; + } + else + { + fun = mpq_div_2exp; + name = "mpq_div_2exp"; + p_start = &data[i].right; + p_want = &data[i].left; + } + + for (sign = 0; sign <= 1; sign++) + { + MPZ_SET_STR_OR_ABORT (mpq_numref(want), p_want->num, 0); + MPZ_SET_STR_OR_ABORT (mpq_denref(want), p_want->den, 0); + if (sign) + mpq_neg (want, want); + + for (overlap = 0; overlap <= 1; overlap++) + { + q = overlap ? got : sep; + + /* initial garbage in "got" */ + mpq_set_ui (got, 123L, 456L); + + MPZ_SET_STR_OR_ABORT (mpq_numref(q), p_start->num, 0); + MPZ_SET_STR_OR_ABORT (mpq_denref(q), p_start->den, 0); + if (sign) + mpq_neg (q, q); + + (*fun) (got, q, data[i].n); + MPQ_CHECK_FORMAT (got); + + if (! mpq_equal (got, want)) + { + printf ("%s wrong at data[%d], sign %d, overlap %d\n", + name, i, sign, overlap); + printf (" num \"%s\"\n", p_start->num); + printf (" den \"%s\"\n", p_start->den); + printf (" n %lu\n", data[i].n); + + printf (" got "); + mpq_out_str (stdout, 16, got); + printf (" (hex)\n"); + + printf (" want "); + mpq_out_str (stdout, 16, want); + printf (" (hex)\n"); + + abort (); + } + } + } + } + } + + exit (0); +} diff --git a/tests/mpq/t-set_f.c b/tests/mpq/t-set_f.c new file mode 100644 index 000000000..f8b0af29d --- /dev/null +++ b/tests/mpq/t-set_f.c @@ -0,0 +1,160 @@ +/* Test mpq_set_f. + +Copyright 2000 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include "gmp.h" +#include "gmp-impl.h" + +int +main (int argc, char **argv) +{ + static const struct { + int f_base; + const char *f; + int z_base; + const char *want_num; + const char *want_den; + + } data[] = { + + { -2, "0", 16, "0", "1" }, + { -2, "1", 16, "1", "1" }, + { -2, "1@1", 16, "2", "1" }, + { -2, "1@2", 16, "4", "1" }, + { -2, "1@3", 16, "8", "1" }, + + { -2, "1@30", 16, "40000000", "1" }, + { -2, "1@31", 16, "80000000", "1" }, + { -2, "1@32", 16, "100000000", "1" }, + { -2, "1@33", 16, "200000000", "1" }, + { -2, "1@34", 16, "400000000", "1" }, + + { -2, "1@62", 16, "4000000000000000", "1" }, + { -2, "1@63", 16, "8000000000000000", "1" }, + { -2, "1@64", 16, "10000000000000000", "1" }, + { -2, "1@65", 16, "20000000000000000", "1" }, + { -2, "1@66", 16, "40000000000000000", "1" }, + + { -2, "1@126", 16, "40000000000000000000000000000000", "1" }, + { -2, "1@127", 16, "80000000000000000000000000000000", "1" }, + { -2, "1@128", 16, "100000000000000000000000000000000", "1" }, + { -2, "1@129", 16, "200000000000000000000000000000000", "1" }, + { -2, "1@130", 16, "400000000000000000000000000000000", "1" }, + + { -2, "1@-1", 16, "1", "2" }, + { -2, "1@-2", 16, "1", "4" }, + { -2, "1@-3", 16, "1", "8" }, + + { -2, "1@-30", 16, "1", "40000000" }, + { -2, "1@-31", 16, "1", "80000000" }, + { -2, "1@-32", 16, "1", "100000000" }, + { -2, "1@-33", 16, "1", "200000000" }, + { -2, "1@-34", 16, "1", "400000000" }, + + { -2, "1@-62", 16, "1", "4000000000000000" }, + { -2, "1@-63", 16, "1", "8000000000000000" }, + { -2, "1@-64", 16, "1", "10000000000000000" }, + { -2, "1@-65", 16, "1", "20000000000000000" }, + { -2, "1@-66", 16, "1", "40000000000000000" }, + + { -2, "1@-126", 16, "1", "40000000000000000000000000000000" }, + { -2, "1@-127", 16, "1", "80000000000000000000000000000000" }, + { -2, "1@-128", 16, "1", "100000000000000000000000000000000" }, + { -2, "1@-129", 16, "1", "200000000000000000000000000000000" }, + { -2, "1@-130", 16, "1", "400000000000000000000000000000000" }, + + { -2, "1@-30", 16, "1", "40000000" }, + { -2, "1@-31", 16, "1", "80000000" }, + { -2, "1@-32", 16, "1", "100000000" }, + { -2, "1@-33", 16, "1", "200000000" }, + { -2, "1@-34", 16, "1", "400000000" }, + + { -2, "11@-62", 16, "3", "4000000000000000" }, + { -2, "11@-63", 16, "3", "8000000000000000" }, + { -2, "11@-64", 16, "3", "10000000000000000" }, + { -2, "11@-65", 16, "3", "20000000000000000" }, + { -2, "11@-66", 16, "3", "40000000000000000" }, + + { 16, "80000000.00000001", 16, "8000000000000001", "100000000" }, + { 16, "80000000.00000008", 16, "1000000000000001", "20000000" }, + { 16, "80000000.8", 16, "100000001", "2" }, + + }; + + mpf_t f; + mpq_t got; + mpz_t want_num, want_den; + int i, neg; + + mpf_init2 (f, 1024); + mpq_init (got); + mpz_init (want_num); + mpz_init (want_den); + + for (i = 0; i < numberof (data); i++) + { + for (neg = 0; neg <= 1; neg++) + { + MPF_SET_STR_OR_ABORT (f, data[i].f, data[i].f_base); + MPZ_SET_STR_OR_ABORT (want_num, data[i].want_num, data[i].z_base); + MPZ_SET_STR_OR_ABORT (want_den, data[i].want_den, data[i].z_base); + + if (neg) + { + mpf_neg (f, f); + mpz_neg (want_num, want_num); + } + + mpq_set_f (got, f); + MPQ_CHECK_FORMAT (got); + + if (mpz_cmp (mpq_numref(got), want_num) != 0 + || mpz_cmp (mpq_denref(got), want_den) != 0) + { + printf ("wrong at data[%d]\n", i); + printf (" f_base %d, z_base %d\n", + data[i].f_base, data[i].z_base); + + printf (" f \"%s\" hex ", data[i].f); + mpf_out_str (stdout, 16, 0, f); + printf ("\n"); + + printf (" want num 0x"); + mpz_out_str (stdout, 16, want_num); + printf ("\n"); + printf (" want den 0x"); + mpz_out_str (stdout, 16, want_den); + printf ("\n"); + + printf (" got num 0x"); + mpz_out_str (stdout, 16, mpq_numref(got)); + printf ("\n"); + printf (" got den 0x"); + mpz_out_str (stdout, 16, mpq_denref(got)); + printf ("\n"); + + abort (); + } + } + } + + exit (0); +} |