Add Chromium-only Blender WebEngine parity work
This commit is contained in:
35
blender-5.2.0/extern/gmp-source/tests/mpq/Makefile.am
vendored
Normal file
35
blender-5.2.0/extern/gmp-source/tests/mpq/Makefile.am
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
# Copyright 1996, 1999-2002, 2012, 2015 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/.
|
||||
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
|
||||
AM_LDFLAGS = -no-install
|
||||
LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
|
||||
|
||||
check_PROGRAMS = t-aors t-cmp t-cmp_ui t-cmp_si t-equal t-get_d t-get_str \
|
||||
t-inp_str t-inv t-md_2exp t-set_f t-set_str io reuse t-cmp_z
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
# Temporary files used by the tests. Removed automatically if the tests
|
||||
# pass, but ensure they're cleaned if they fail.
|
||||
#
|
||||
CLEANFILES = *.tmp
|
||||
|
||||
$(top_builddir)/tests/libtests.la:
|
||||
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
|
||||
1241
blender-5.2.0/extern/gmp-source/tests/mpq/Makefile.in
vendored
Normal file
1241
blender-5.2.0/extern/gmp-source/tests/mpq/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load Diff
136
blender-5.2.0/extern/gmp-source/tests/mpq/io.c
vendored
Normal file
136
blender-5.2.0/extern/gmp-source/tests/mpq/io.c
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/* Test conversion and I/O using mpq_out_str and mpq_inp_str.
|
||||
|
||||
Copyright 1993, 1994, 1996, 2000, 2001, 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for unlink */
|
||||
#endif
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#define FILENAME "io.tmp"
|
||||
|
||||
void
|
||||
debug_mp (mpq_t x, int base)
|
||||
{
|
||||
mpq_out_str (stdout, base, x); fputc ('\n', stdout);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mpq_t op1, op2;
|
||||
mp_size_t size;
|
||||
int i;
|
||||
int reps = 10000;
|
||||
FILE *fp;
|
||||
int base;
|
||||
gmp_randstate_ptr rands;
|
||||
mpz_t bs;
|
||||
unsigned long bsi, size_range;
|
||||
size_t nread;
|
||||
|
||||
tests_start ();
|
||||
rands = RANDS;
|
||||
|
||||
mpz_init (bs);
|
||||
|
||||
if (argc == 2)
|
||||
reps = atoi (argv[1]);
|
||||
|
||||
mpq_init (op1);
|
||||
mpq_init (op2);
|
||||
|
||||
fp = fopen (FILENAME, "w+");
|
||||
|
||||
for (i = 0; i < reps; i++)
|
||||
{
|
||||
mpz_urandomb (bs, rands, 32);
|
||||
size_range = mpz_get_ui (bs) % 10 + 2;
|
||||
|
||||
mpz_urandomb (bs, rands, size_range);
|
||||
size = mpz_get_ui (bs) + 2;
|
||||
mpz_errandomb (mpq_numref(op1), rands, size);
|
||||
mpz_errandomb_nonzero (mpq_denref(op1), rands, size);
|
||||
mpq_canonicalize (op1);
|
||||
|
||||
mpz_urandomb (bs, rands, 1);
|
||||
bsi = mpz_get_ui (bs);
|
||||
if ((bsi & 1) != 0)
|
||||
mpq_neg (op1, op1);
|
||||
|
||||
mpz_urandomb (bs, rands, 16);
|
||||
bsi = mpz_get_ui (bs);
|
||||
base = bsi % 36 + 1;
|
||||
if (base == 1)
|
||||
base = 0;
|
||||
|
||||
rewind (fp);
|
||||
if (mpq_out_str (fp, base, op1) == 0
|
||||
|| putc (' ', fp) == EOF
|
||||
|| fflush (fp) != 0)
|
||||
{
|
||||
printf ("mpq_out_str write error\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
rewind (fp);
|
||||
nread = mpq_inp_str (op2, fp, base);
|
||||
if (nread == 0)
|
||||
{
|
||||
if (ferror (fp))
|
||||
printf ("mpq_inp_str stream read error\n");
|
||||
else
|
||||
printf ("mpq_inp_str data conversion error\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (nread != ftell(fp))
|
||||
{
|
||||
printf ("mpq_inp_str nread doesn't match ftell\n");
|
||||
printf (" nread %lu\n", (unsigned long) nread);
|
||||
printf (" ftell %ld\n", ftell(fp));
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (mpq_cmp (op1, op2))
|
||||
{
|
||||
printf ("ERROR\n");
|
||||
printf ("op1 = "); debug_mp (op1, -16);
|
||||
printf ("op2 = "); debug_mp (op2, -16);
|
||||
printf ("base = %d\n", base);
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
unlink (FILENAME);
|
||||
|
||||
mpz_clear (bs);
|
||||
mpq_clear (op1);
|
||||
mpq_clear (op2);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
245
blender-5.2.0/extern/gmp-source/tests/mpq/reuse.c
vendored
Normal file
245
blender-5.2.0/extern/gmp-source/tests/mpq/reuse.c
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
/* Test that routines allow reusing a source variable as destination.
|
||||
|
||||
Copyright 1996, 2000-2002, 2012, 2015 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#if __GMP_LIBGMP_DLL
|
||||
|
||||
/* FIXME: When linking to a DLL libgmp, mpq_add etc can't be used as
|
||||
initializers for global variables because they're effectively global
|
||||
variables (function pointers) themselves. Perhaps calling a test
|
||||
function successively with mpq_add etc would be better. */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
printf ("Test suppressed for windows DLL\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
#else /* ! DLL_EXPORT */
|
||||
|
||||
#ifndef SIZE
|
||||
#define SIZE 16
|
||||
#endif
|
||||
|
||||
void dump_abort (const char *, mpq_t, mpq_t);
|
||||
|
||||
typedef void (*dss_func) (mpq_ptr, mpq_srcptr, mpq_srcptr);
|
||||
|
||||
dss_func dss_funcs[] =
|
||||
{
|
||||
mpq_div, mpq_add, mpq_mul, mpq_sub,
|
||||
};
|
||||
|
||||
const char *dss_func_names[] =
|
||||
{
|
||||
"mpq_div", "mpq_add", "mpq_mul", "mpq_sub",
|
||||
};
|
||||
|
||||
typedef void (*ds_func) (mpq_ptr, mpq_srcptr);
|
||||
|
||||
ds_func ds_funcs[] =
|
||||
{
|
||||
mpq_abs, mpq_neg,
|
||||
};
|
||||
|
||||
const char *ds_func_names[] =
|
||||
{
|
||||
"mpq_abs", "mpq_neg",
|
||||
};
|
||||
|
||||
typedef void (*dsi_func) (mpq_ptr, mpq_srcptr, unsigned long int);
|
||||
|
||||
dsi_func dsi_funcs[] =
|
||||
{
|
||||
mpq_mul_2exp, mpq_div_2exp
|
||||
};
|
||||
|
||||
const char *dsi_func_names[] =
|
||||
{
|
||||
"mpq_mul_2exp", "mpq_div_2exp"
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int pass, reps = 100;
|
||||
mpq_t in1, in2, out1;
|
||||
unsigned long int randbits, in2i;
|
||||
mpq_t res1, res2;
|
||||
gmp_randstate_ptr rands;
|
||||
|
||||
tests_start ();
|
||||
|
||||
TESTS_REPS (reps, argv, argc);
|
||||
|
||||
rands = RANDS;
|
||||
|
||||
mpq_init (in1);
|
||||
mpq_init (in2);
|
||||
mpq_init (out1);
|
||||
mpq_init (res1);
|
||||
mpq_init (res2);
|
||||
|
||||
for (pass = 1; pass <= reps; pass++)
|
||||
{
|
||||
randbits = urandom ();
|
||||
|
||||
if (randbits & 1)
|
||||
{
|
||||
mpq_clear (in1);
|
||||
mpq_init (in1);
|
||||
}
|
||||
randbits >>= 1;
|
||||
mpz_errandomb (mpq_numref(in1), rands, 512L);
|
||||
mpz_errandomb_nonzero (mpq_denref(in1), rands, 512L);
|
||||
if (randbits & 1)
|
||||
mpz_neg (mpq_numref(in1),mpq_numref(in1));
|
||||
randbits >>= 1;
|
||||
mpq_canonicalize (in1);
|
||||
|
||||
if (randbits & 1)
|
||||
{
|
||||
mpq_clear (in2);
|
||||
mpq_init (in2);
|
||||
}
|
||||
randbits >>= 1;
|
||||
mpz_errandomb (mpq_numref(in2), rands, 512L);
|
||||
mpz_errandomb_nonzero (mpq_denref(in2), rands, 512L);
|
||||
if (randbits & 1)
|
||||
mpz_neg (mpq_numref(in2),mpq_numref(in2));
|
||||
randbits >>= 1;
|
||||
mpq_canonicalize (in2);
|
||||
|
||||
for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++)
|
||||
{
|
||||
/* Don't divide by 0. */
|
||||
if (i == 0 && mpq_cmp_ui (in2, 0, 1) == 0)
|
||||
continue;
|
||||
|
||||
if (randbits & 1)
|
||||
{
|
||||
mpq_clear (res1);
|
||||
mpq_init (res1);
|
||||
}
|
||||
randbits >>= 1;
|
||||
|
||||
(dss_funcs[i]) (res1, in1, in2);
|
||||
MPQ_CHECK_FORMAT(res1);
|
||||
|
||||
mpq_set (out1, in1);
|
||||
(dss_funcs[i]) (out1, out1, in2);
|
||||
MPQ_CHECK_FORMAT(out1);
|
||||
|
||||
if (mpq_cmp (res1, out1) != 0)
|
||||
dump_abort (dss_func_names[i], res1, out1);
|
||||
|
||||
mpq_set (out1, in2);
|
||||
(dss_funcs[i]) (out1, in1, out1);
|
||||
MPQ_CHECK_FORMAT(out1);
|
||||
|
||||
if (mpq_cmp (res1, out1) != 0)
|
||||
dump_abort (dss_func_names[i], res1, out1);
|
||||
|
||||
mpq_set (out1, in2);
|
||||
(dss_funcs[i]) (res1, out1, in2);
|
||||
MPQ_CHECK_FORMAT(res1);
|
||||
|
||||
(dss_funcs[i]) (res2, in2, in2);
|
||||
MPQ_CHECK_FORMAT(res2);
|
||||
|
||||
(dss_funcs[i]) (out1, out1, out1);
|
||||
MPQ_CHECK_FORMAT(out1);
|
||||
|
||||
if (mpq_cmp (res1, res2) != 0)
|
||||
dump_abort (dss_func_names[i], res1, res2);
|
||||
if (mpq_cmp (res1, out1) != 0)
|
||||
dump_abort (dss_func_names[i], res1, out1);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof (ds_funcs) / sizeof (ds_func); i++)
|
||||
{
|
||||
if (randbits & 1)
|
||||
{
|
||||
mpq_clear (res1);
|
||||
mpq_init (res1);
|
||||
}
|
||||
randbits >>= 1;
|
||||
(ds_funcs[i]) (res1, in1);
|
||||
MPQ_CHECK_FORMAT(res1);
|
||||
|
||||
mpq_set (out1, in1);
|
||||
(ds_funcs[i]) (out1, out1);
|
||||
MPQ_CHECK_FORMAT(out1);
|
||||
|
||||
if (mpq_cmp (res1, out1) != 0)
|
||||
dump_abort (ds_func_names[i], res1, out1);
|
||||
}
|
||||
|
||||
in2i = urandom () % 65536;
|
||||
for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++)
|
||||
{
|
||||
if (randbits & 1)
|
||||
{
|
||||
mpq_clear (res1);
|
||||
mpq_init (res1);
|
||||
}
|
||||
randbits >>= 1;
|
||||
|
||||
(dsi_funcs[i]) (res1, in1, in2i);
|
||||
MPQ_CHECK_FORMAT(res1);
|
||||
|
||||
mpq_set (out1, in1);
|
||||
(dsi_funcs[i]) (out1, out1, in2i);
|
||||
MPQ_CHECK_FORMAT(out1);
|
||||
|
||||
if (mpq_cmp (res1, out1) != 0)
|
||||
dump_abort (dsi_func_names[i], res1, out1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mpq_clear (in1);
|
||||
mpq_clear (in2);
|
||||
mpq_clear (out1);
|
||||
mpq_clear (res1);
|
||||
mpq_clear (res2);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
void
|
||||
dump_abort (const char *name, mpq_t res1, mpq_t res2)
|
||||
{
|
||||
printf ("failure in %s:\n", name);
|
||||
mpq_trace (" res1 ", res1);
|
||||
mpq_trace (" res2 ", res2);
|
||||
abort ();
|
||||
}
|
||||
|
||||
#endif /* ! DLL_EXPORT */
|
||||
182
blender-5.2.0/extern/gmp-source/tests/mpq/t-aors.c
vendored
Normal file
182
blender-5.2.0/extern/gmp-source/tests/mpq/t-aors.c
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/* Test mpq_add and mpq_sub.
|
||||
|
||||
Copyright 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
void
|
||||
check_all (mpq_ptr x, mpq_ptr y, mpq_ptr want_add, mpq_ptr want_sub)
|
||||
{
|
||||
mpq_t got;
|
||||
int neg_x, neg_y, swap;
|
||||
|
||||
mpq_init (got);
|
||||
|
||||
MPQ_CHECK_FORMAT (want_add);
|
||||
MPQ_CHECK_FORMAT (want_sub);
|
||||
MPQ_CHECK_FORMAT (x);
|
||||
MPQ_CHECK_FORMAT (y);
|
||||
|
||||
for (swap = 0; swap <= 1; swap++)
|
||||
{
|
||||
for (neg_x = 0; neg_x <= 1; neg_x++)
|
||||
{
|
||||
for (neg_y = 0; neg_y <= 1; neg_y++)
|
||||
{
|
||||
mpq_add (got, x, y);
|
||||
MPQ_CHECK_FORMAT (got);
|
||||
if (! mpq_equal (got, want_add))
|
||||
{
|
||||
printf ("mpq_add wrong\n");
|
||||
mpq_trace (" x ", x);
|
||||
mpq_trace (" y ", y);
|
||||
mpq_trace (" got ", got);
|
||||
mpq_trace (" want", want_add);
|
||||
abort ();
|
||||
}
|
||||
|
||||
mpq_sub (got, x, y);
|
||||
MPQ_CHECK_FORMAT (got);
|
||||
if (! mpq_equal (got, want_sub))
|
||||
{
|
||||
printf ("mpq_sub wrong\n");
|
||||
mpq_trace (" x ", x);
|
||||
mpq_trace (" y ", y);
|
||||
mpq_trace (" got ", got);
|
||||
mpq_trace (" want", want_sub);
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
mpq_neg (y, y);
|
||||
mpq_swap (want_add, want_sub);
|
||||
}
|
||||
|
||||
mpq_neg (x, x);
|
||||
mpq_swap (want_add, want_sub);
|
||||
mpq_neg (want_add, want_add);
|
||||
mpq_neg (want_sub, want_sub);
|
||||
}
|
||||
|
||||
mpq_swap (x, y);
|
||||
mpq_neg (want_sub, want_sub);
|
||||
}
|
||||
|
||||
mpq_clear (got);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
check_data (void)
|
||||
{
|
||||
static const struct {
|
||||
const char *x;
|
||||
const char *y;
|
||||
const char *want_add;
|
||||
const char *want_sub;
|
||||
|
||||
} data[] = {
|
||||
|
||||
{ "0", "0", "0", "0" },
|
||||
{ "1", "0", "1", "1" },
|
||||
{ "1", "1", "2", "0" },
|
||||
|
||||
{ "1/2", "1/2", "1", "0" },
|
||||
{ "5/6", "14/15", "53/30", "-1/10" },
|
||||
};
|
||||
|
||||
mpq_t x, y, want_add, want_sub;
|
||||
int i;
|
||||
|
||||
mpq_init (x);
|
||||
mpq_init (y);
|
||||
mpq_init (want_add);
|
||||
mpq_init (want_sub);
|
||||
|
||||
for (i = 0; i < numberof (data); i++)
|
||||
{
|
||||
mpq_set_str_or_abort (x, data[i].x, 0);
|
||||
mpq_set_str_or_abort (y, data[i].y, 0);
|
||||
mpq_set_str_or_abort (want_add, data[i].want_add, 0);
|
||||
mpq_set_str_or_abort (want_sub, data[i].want_sub, 0);
|
||||
|
||||
check_all (x, y, want_add, want_sub);
|
||||
}
|
||||
|
||||
mpq_clear (x);
|
||||
mpq_clear (y);
|
||||
mpq_clear (want_add);
|
||||
mpq_clear (want_sub);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
check_rand (void)
|
||||
{
|
||||
mpq_t x, y, want_add, want_sub;
|
||||
int i;
|
||||
gmp_randstate_ptr rands = RANDS;
|
||||
|
||||
mpq_init (x);
|
||||
mpq_init (y);
|
||||
mpq_init (want_add);
|
||||
mpq_init (want_sub);
|
||||
|
||||
for (i = 0; i < 500; i++)
|
||||
{
|
||||
mpz_errandomb (mpq_numref(x), rands, 512L);
|
||||
mpz_errandomb_nonzero (mpq_denref(x), rands, 512L);
|
||||
mpq_canonicalize (x);
|
||||
|
||||
mpz_errandomb (mpq_numref(y), rands, 512L);
|
||||
mpz_errandomb_nonzero (mpq_denref(y), rands, 512L);
|
||||
mpq_canonicalize (y);
|
||||
|
||||
refmpq_add (want_add, x, y);
|
||||
refmpq_sub (want_sub, x, y);
|
||||
|
||||
check_all (x, y, want_add, want_sub);
|
||||
}
|
||||
|
||||
mpq_clear (x);
|
||||
mpq_clear (y);
|
||||
mpq_clear (want_add);
|
||||
mpq_clear (want_sub);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_data ();
|
||||
check_rand ();
|
||||
|
||||
tests_end ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
101
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp.c
vendored
Normal file
101
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp.c
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/* Test mpq_cmp.
|
||||
|
||||
Copyright 1996, 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#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 probability of finding an error */
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mpq_t a, b;
|
||||
mp_size_t size;
|
||||
int reps = 10000;
|
||||
int i;
|
||||
int cc, ccref;
|
||||
|
||||
tests_start ();
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
mpq_clear (a);
|
||||
mpq_clear (b);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
117
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_si.c
vendored
Normal file
117
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_si.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/* Test mpq_cmp_si.
|
||||
|
||||
Copyright 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
#define SGN(x) ((x)<0 ? -1 : (x) != 0)
|
||||
|
||||
void
|
||||
check_data (void)
|
||||
{
|
||||
static const struct {
|
||||
const char *q;
|
||||
long n;
|
||||
unsigned long d;
|
||||
int want;
|
||||
} data[] = {
|
||||
{ "0", 0, 1, 0 },
|
||||
{ "0", 0, 123, 0 },
|
||||
{ "0", 0, ULONG_MAX, 0 },
|
||||
{ "1", 0, 1, 1 },
|
||||
{ "1", 0, 123, 1 },
|
||||
{ "1", 0, ULONG_MAX, 1 },
|
||||
{ "-1", 0, 1, -1 },
|
||||
{ "-1", 0, 123, -1 },
|
||||
{ "-1", 0, ULONG_MAX, -1 },
|
||||
|
||||
{ "123", 123, 1, 0 },
|
||||
{ "124", 123, 1, 1 },
|
||||
{ "122", 123, 1, -1 },
|
||||
|
||||
{ "-123", 123, 1, -1 },
|
||||
{ "-124", 123, 1, -1 },
|
||||
{ "-122", 123, 1, -1 },
|
||||
|
||||
{ "123", -123, 1, 1 },
|
||||
{ "124", -123, 1, 1 },
|
||||
{ "122", -123, 1, 1 },
|
||||
|
||||
{ "-123", -123, 1, 0 },
|
||||
{ "-124", -123, 1, -1 },
|
||||
{ "-122", -123, 1, 1 },
|
||||
|
||||
{ "5/7", 3,4, -1 },
|
||||
{ "5/7", -3,4, 1 },
|
||||
{ "-5/7", 3,4, -1 },
|
||||
{ "-5/7", -3,4, 1 },
|
||||
};
|
||||
|
||||
mpq_t q;
|
||||
int i, got;
|
||||
|
||||
mpq_init (q);
|
||||
|
||||
for (i = 0; i < numberof (data); i++)
|
||||
{
|
||||
mpq_set_str_or_abort (q, data[i].q, 0);
|
||||
MPQ_CHECK_FORMAT (q);
|
||||
|
||||
got = mpq_cmp_si (q, data[i].n, data[i].d);
|
||||
if (SGN(got) != data[i].want)
|
||||
{
|
||||
printf ("mpq_cmp_si wrong\n");
|
||||
error:
|
||||
mpq_trace (" q", q);
|
||||
printf (" n=%ld\n", data[i].n);
|
||||
printf (" d=%lu\n", data[i].d);
|
||||
printf (" got=%d\n", got);
|
||||
printf (" want=%d\n", data[i].want);
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (data[i].n == 0)
|
||||
{
|
||||
got = mpq_cmp_si (q, 0L, data[i].d);
|
||||
if (SGN(got) != data[i].want)
|
||||
{
|
||||
printf ("mpq_cmp_si wrong\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mpq_clear (q);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_data ();
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
116
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_ui.c
vendored
Normal file
116
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_ui.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/* Test mpq_cmp_ui.
|
||||
|
||||
Copyright 1996, 1997, 2001, 2002 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#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 probability of finding an error */
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mpq_t a, b;
|
||||
mp_size_t size;
|
||||
int reps = 10000;
|
||||
int i;
|
||||
int cc, ccref;
|
||||
unsigned long int bn, bd;
|
||||
|
||||
tests_start ();
|
||||
|
||||
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), (mp_size_t) 1);
|
||||
mpz_mod_ui (NUM (b), NUM (b), ~(unsigned long int) 0);
|
||||
mpz_add_ui (NUM (b), NUM (b), 1);
|
||||
|
||||
mpz_random2 (DEN (b), (mp_size_t) 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);
|
||||
|
||||
ccref = ref_mpq_cmp_ui (a, 1, 1);
|
||||
cc = mpq_cmp_ui (a, 1, 1);
|
||||
|
||||
if (SGN (ccref) != SGN (cc))
|
||||
abort ();
|
||||
|
||||
ccref = ref_mpq_cmp_ui (a, 0, 1);
|
||||
cc = mpq_cmp_ui (a, 0, 1);
|
||||
|
||||
if (SGN (ccref) != SGN (cc))
|
||||
abort ();
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
mpq_clear (a);
|
||||
mpq_clear (b);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
146
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_z.c
vendored
Normal file
146
blender-5.2.0/extern/gmp-source/tests/mpq/t-cmp_z.c
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/* Test mpq_cmp_z.
|
||||
|
||||
Copyright 1996, 2001, 2015 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#define SGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0)
|
||||
|
||||
int
|
||||
ref_mpq_cmp_z (mpq_t a, mpz_t b)
|
||||
{
|
||||
mpz_t bi;
|
||||
int cc;
|
||||
|
||||
mpz_init (bi);
|
||||
|
||||
mpz_mul (bi, b, DEN (a));
|
||||
cc = mpz_cmp (NUM (a), bi);
|
||||
mpz_clear (bi);
|
||||
return cc;
|
||||
}
|
||||
|
||||
#ifndef SIZE
|
||||
#define SIZE 8 /* increasing this lowers the probability of finding an error */
|
||||
#endif
|
||||
|
||||
#ifndef MAXN
|
||||
#define MAXN 5 /* increasing this impatcs on total timing */
|
||||
#endif
|
||||
|
||||
void
|
||||
sizes_test (int m)
|
||||
{
|
||||
mpq_t a;
|
||||
mpz_t b;
|
||||
int i, j, k, s;
|
||||
int cc, ccref;
|
||||
|
||||
mpq_init (a);
|
||||
mpz_init (b);
|
||||
|
||||
for (i = 0; i <= MAXN ; ++i)
|
||||
{
|
||||
mpz_setbit (DEN (a), i*m); /* \sum_0^i 2^(i*m) */
|
||||
for (j = 0; j <= MAXN; ++j)
|
||||
{
|
||||
mpz_set_ui (NUM (a), 0);
|
||||
mpz_setbit (NUM (a), j*m); /* 2^(j*m) */
|
||||
for (k = 0; k <= MAXN; ++k)
|
||||
{
|
||||
mpz_set_ui (b, 0);
|
||||
mpz_setbit (b, k*m); /* 2^(k*m) */
|
||||
if (i == 0) /* Denominator is 1, compare the two exponents */
|
||||
ccref = (j>k)-(j<k);
|
||||
else
|
||||
ccref = j-i > k ? 1 : -1;
|
||||
for (s = 1; s >= -1; s -= 2)
|
||||
{
|
||||
cc = mpq_cmp_z (a, b);
|
||||
|
||||
if (ccref != SGN (cc))
|
||||
{
|
||||
fprintf (stderr, "i=%i, j=%i, k=%i, m=%i, s=%i\n; ccref= %i, cc= %i\n", i, j, k, m, s, ccref, cc);
|
||||
abort ();
|
||||
}
|
||||
|
||||
mpq_neg (a, a);
|
||||
mpz_neg (b, b);
|
||||
ccref = - ccref;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mpq_clear (a);
|
||||
mpz_clear (b);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mpq_t a;
|
||||
mpz_t b;
|
||||
mp_size_t size;
|
||||
int reps = 10000;
|
||||
int i;
|
||||
int cc, ccref;
|
||||
|
||||
tests_start ();
|
||||
|
||||
if (argc == 2)
|
||||
reps = atoi (argv[1]);
|
||||
|
||||
mpq_init (a);
|
||||
mpz_init (b);
|
||||
|
||||
for (i = 0; i < reps; i++)
|
||||
{
|
||||
if (i % 8192 == 0)
|
||||
sizes_test (urandom () % (i + 1) + 1);
|
||||
size = urandom () % SIZE - SIZE/2;
|
||||
mpz_random2 (NUM (a), size);
|
||||
do
|
||||
{
|
||||
size = urandom () % (SIZE/2);
|
||||
mpz_random2 (DEN (a), size);
|
||||
}
|
||||
while (mpz_cmp_ui (DEN (a), 0) == 0);
|
||||
|
||||
size = urandom () % SIZE - SIZE/2;
|
||||
mpz_random2 (b, size);
|
||||
|
||||
mpq_canonicalize (a);
|
||||
|
||||
ccref = ref_mpq_cmp_z (a, b);
|
||||
cc = mpq_cmp_z (a, b);
|
||||
|
||||
if (SGN (ccref) != SGN (cc))
|
||||
abort ();
|
||||
}
|
||||
|
||||
mpq_clear (a);
|
||||
mpz_clear (b);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
146
blender-5.2.0/extern/gmp-source/tests/mpq/t-equal.c
vendored
Normal file
146
blender-5.2.0/extern/gmp-source/tests/mpq/t-equal.c
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/* Test mpq_equal.
|
||||
|
||||
Copyright 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
void
|
||||
check_one (mpq_srcptr x, mpq_srcptr y, int want)
|
||||
{
|
||||
int got;
|
||||
|
||||
MPQ_CHECK_FORMAT (x);
|
||||
MPQ_CHECK_FORMAT (y);
|
||||
|
||||
got = mpq_equal (x, y);
|
||||
if ((got != 0) != (want != 0))
|
||||
{
|
||||
printf ("mpq_equal got %d want %d\n", got, want);
|
||||
mpq_trace ("x", x);
|
||||
mpq_trace ("y", y);
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
check_all (mpq_ptr x, mpq_ptr y, int want)
|
||||
{
|
||||
check_one (x, y, want);
|
||||
check_one (y, x, want);
|
||||
|
||||
mpq_neg (x, x);
|
||||
mpq_neg (y, y);
|
||||
|
||||
check_one (x, y, want);
|
||||
check_one (y, x, want);
|
||||
}
|
||||
|
||||
|
||||
#define SET4Z(z, size,l3,l2,l1,l0) \
|
||||
SIZ(z) = size; PTR(z)[3] = l3; PTR(z)[2] = l2; PTR(z)[1] = l1; PTR(z)[0] = l0
|
||||
|
||||
#define SET4(q, nsize,n3,n2,n1,n0, dsize,d3,d2,d1,d0) \
|
||||
SET4Z (mpq_numref(q), nsize,n3,n2,n1,n0); \
|
||||
SET4Z (mpq_denref(q), dsize,d3,d2,d1,d0)
|
||||
|
||||
|
||||
/* Exercise various combinations of same and slightly different values. */
|
||||
|
||||
void
|
||||
check_various (void)
|
||||
{
|
||||
mpq_t x, y;
|
||||
|
||||
mpq_init (x);
|
||||
mpq_init (y);
|
||||
|
||||
mpz_realloc (mpq_numref(x), (mp_size_t) 20);
|
||||
mpz_realloc (mpq_denref(x), (mp_size_t) 20);
|
||||
mpz_realloc (mpq_numref(y), (mp_size_t) 20);
|
||||
mpz_realloc (mpq_denref(y), (mp_size_t) 20);
|
||||
|
||||
/* 0 == 0 */
|
||||
SET4 (x, 0,13,12,11,10, 1,23,22,21,1);
|
||||
SET4 (y, 0,33,32,31,30, 1,43,42,41,1);
|
||||
check_all (x, y, 1);
|
||||
|
||||
/* 83/99 == 83/99 */
|
||||
SET4 (x, 1,13,12,11,83, 1,23,22,21,99);
|
||||
SET4 (y, 1,33,32,31,83, 1,43,42,41,99);
|
||||
check_all (x, y, 1);
|
||||
|
||||
/* 1:2:3:4/5:6:7 == 1:2:3:4/5:6:7 */
|
||||
SET4 (x, 4,1,2,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 1);
|
||||
|
||||
/* various individual changes making != */
|
||||
SET4 (x, 4,1,2,3,667, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 4,1,2,666,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 4,1,666,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
#if GMP_NUMB_BITS != 62
|
||||
SET4 (x, 4,667,2,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
#endif
|
||||
SET4 (x, 4,1,2,3,4, 3,88,5,6,667);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 4,1,2,3,4, 3,88,5,667,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 4,1,2,3,4, 3,88,666,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, -4,1,2,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 1,1,2,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
SET4 (x, 4,1,2,3,4, 3,88,5,6,7);
|
||||
SET4 (y, 4,1,2,3,4, 2,99,5,6,7);
|
||||
check_all (x, y, 0);
|
||||
|
||||
mpq_clear (x);
|
||||
mpq_clear (y);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
tests_start ();
|
||||
mp_trace_base = -16;
|
||||
|
||||
check_various ();
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
294
blender-5.2.0/extern/gmp-source/tests/mpq/t-get_d.c
vendored
Normal file
294
blender-5.2.0/extern/gmp-source/tests/mpq/t-get_d.c
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
/* Test mpq_get_d and mpq_set_d
|
||||
|
||||
Copyright 1991, 1993, 1994, 1996, 2000-2003, 2012, 2013 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
#ifndef SIZE
|
||||
#define SIZE 8
|
||||
#endif
|
||||
|
||||
/* VAX D floats only have an 8 bit signed exponent, so anything 2^128 or
|
||||
bigger will overflow, that being 4 limbs. */
|
||||
#if defined (__vax) || defined (__vax__) && SIZE > 4
|
||||
#undef SIZE
|
||||
#define SIZE 4
|
||||
#define EPSIZE 3
|
||||
#else
|
||||
#define EPSIZE SIZE
|
||||
#endif
|
||||
|
||||
void dump (mpq_t);
|
||||
|
||||
void
|
||||
check_monotonic (int argc, char **argv)
|
||||
{
|
||||
mpq_t a;
|
||||
mp_size_t size;
|
||||
int reps = 100;
|
||||
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 () % EPSIZE + 1;
|
||||
mpz_random2 (mpq_numref (eps), size);
|
||||
size = urandom () % EPSIZE + 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)
|
||||
{
|
||||
printf ("\nERROR (test %d/%d): bad mpq_get_d results\n", i, j);
|
||||
printf ("last: %.16g\n", last_d);
|
||||
printf (" new: %.16g\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)
|
||||
{
|
||||
printf ("ERROR (test %d/%d): bad mpq_set_d results\n", i, j);
|
||||
printf ("last: %.16g\n", last_d); dump (qlast_d);
|
||||
printf (" new: %.16g\n", new_d); dump (qnew_d);
|
||||
abort ();
|
||||
}
|
||||
last_d = new_d;
|
||||
mpq_set (qlast_d, qnew_d);
|
||||
}
|
||||
}
|
||||
|
||||
mpq_clear (a);
|
||||
mpq_clear (eps);
|
||||
mpq_clear (qlast_d);
|
||||
mpq_clear (qnew_d);
|
||||
}
|
||||
|
||||
double
|
||||
my_ldexp (double d, int e)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (e > 0)
|
||||
{
|
||||
if (e >= 16)
|
||||
{
|
||||
d *= 65536.0;
|
||||
e -= 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
d *= 2.0;
|
||||
e -= 1;
|
||||
}
|
||||
}
|
||||
else if (e < 0)
|
||||
{
|
||||
|
||||
if (e <= -16)
|
||||
{
|
||||
d /= 65536.0;
|
||||
e += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
d /= 2.0;
|
||||
e += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAXEXP 500
|
||||
|
||||
#if defined (__vax) || defined (__vax__)
|
||||
#undef MAXEXP
|
||||
#define MAXEXP 30
|
||||
#endif
|
||||
|
||||
void
|
||||
check_random (int argc, char **argv)
|
||||
{
|
||||
gmp_randstate_ptr rands = RANDS;
|
||||
|
||||
double d;
|
||||
mpq_t q;
|
||||
mpz_t a, t;
|
||||
int exp;
|
||||
|
||||
int test, reps = 100000;
|
||||
|
||||
if (argc == 2)
|
||||
reps = 100 * atoi (argv[1]);
|
||||
|
||||
mpq_init (q);
|
||||
mpz_init (a);
|
||||
mpz_init (t);
|
||||
|
||||
for (test = 0; test < reps; test++)
|
||||
{
|
||||
mpz_rrandomb (a, rands, 53);
|
||||
mpz_urandomb (t, rands, 32);
|
||||
exp = mpz_get_ui (t) % (2*MAXEXP) - MAXEXP;
|
||||
|
||||
d = my_ldexp (mpz_get_d (a), exp);
|
||||
mpq_set_d (q, d);
|
||||
/* Check that n/d = a * 2^exp, or
|
||||
d*a 2^{exp} = n */
|
||||
mpz_mul (t, a, mpq_denref (q));
|
||||
if (exp > 0)
|
||||
mpz_mul_2exp (t, t, exp);
|
||||
else
|
||||
{
|
||||
if (!mpz_divisible_2exp_p (t, -exp))
|
||||
goto fail;
|
||||
mpz_div_2exp (t, t, -exp);
|
||||
}
|
||||
if (mpz_cmp (t, mpq_numref (q)) != 0)
|
||||
{
|
||||
fail:
|
||||
printf ("ERROR (check_random test %d): bad mpq_set_d results\n", test);
|
||||
printf ("%.16g\n", d);
|
||||
gmp_printf ("%Qd\n", q);
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
mpq_clear (q);
|
||||
mpz_clear (t);
|
||||
mpz_clear (a);
|
||||
}
|
||||
|
||||
void
|
||||
dump (mpq_t x)
|
||||
{
|
||||
mpz_out_str (stdout, 10, mpq_numref (x));
|
||||
printf ("/");
|
||||
mpz_out_str (stdout, 10, mpq_denref (x));
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
/* Check various values 2^n and 1/2^n. */
|
||||
void
|
||||
check_onebit (void)
|
||||
{
|
||||
static const long data[] = {
|
||||
-3*GMP_NUMB_BITS-1, -3*GMP_NUMB_BITS, -3*GMP_NUMB_BITS+1,
|
||||
-2*GMP_NUMB_BITS-1, -2*GMP_NUMB_BITS, -2*GMP_NUMB_BITS+1,
|
||||
-GMP_NUMB_BITS-1, -GMP_NUMB_BITS, -GMP_NUMB_BITS+1,
|
||||
-5, -2, -1, 0, 1, 2, 5,
|
||||
GMP_NUMB_BITS-1, GMP_NUMB_BITS, GMP_NUMB_BITS+1,
|
||||
2*GMP_NUMB_BITS-1, 2*GMP_NUMB_BITS, 2*GMP_NUMB_BITS+1,
|
||||
3*GMP_NUMB_BITS-1, 3*GMP_NUMB_BITS, 3*GMP_NUMB_BITS+1,
|
||||
};
|
||||
|
||||
int i, neg;
|
||||
long exp, l;
|
||||
mpq_t q;
|
||||
double got, want;
|
||||
|
||||
mpq_init (q);
|
||||
|
||||
for (i = 0; i < numberof (data); i++)
|
||||
{
|
||||
exp = data[i];
|
||||
|
||||
mpq_set_ui (q, 1L, 1L);
|
||||
if (exp >= 0)
|
||||
mpq_mul_2exp (q, q, exp);
|
||||
else
|
||||
mpq_div_2exp (q, q, -exp);
|
||||
|
||||
want = 1.0;
|
||||
for (l = 0; l < exp; l++)
|
||||
want *= 2.0;
|
||||
for (l = 0; l > exp; l--)
|
||||
want /= 2.0;
|
||||
|
||||
for (neg = 0; neg <= 1; neg++)
|
||||
{
|
||||
if (neg)
|
||||
{
|
||||
mpq_neg (q, q);
|
||||
want = -want;
|
||||
}
|
||||
|
||||
got = mpq_get_d (q);
|
||||
|
||||
if (got != want)
|
||||
{
|
||||
printf ("mpq_get_d wrong on %s2**%ld\n", neg ? "-" : "", exp);
|
||||
mpq_trace (" q ", q);
|
||||
d_trace (" want ", want);
|
||||
d_trace (" got ", got);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
mpq_clear (q);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_onebit ();
|
||||
check_monotonic (argc, argv);
|
||||
check_random (argc, argv);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
142
blender-5.2.0/extern/gmp-source/tests/mpq/t-get_str.c
vendored
Normal file
142
blender-5.2.0/extern/gmp-source/tests/mpq/t-get_str.c
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/* Test mpq_get_str.
|
||||
|
||||
Copyright 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
void
|
||||
check_one (mpq_srcptr q, int base, const char *want)
|
||||
{
|
||||
char *str, *ret;
|
||||
size_t str_alloc;
|
||||
|
||||
MPQ_CHECK_FORMAT (q);
|
||||
mp_trace_base = base;
|
||||
|
||||
str_alloc =
|
||||
mpz_sizeinbase (mpq_numref(q), ABS(base)) +
|
||||
mpz_sizeinbase (mpq_denref(q), ABS(base)) + 3;
|
||||
|
||||
str = mpq_get_str (NULL, base, q);
|
||||
if (strlen(str)+1 > str_alloc)
|
||||
{
|
||||
printf ("mpq_get_str size bigger than should be (passing NULL)\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" got size %lu \"%s\"\n", (unsigned long) strlen(str)+1, str);
|
||||
printf (" want size %lu\n", (unsigned long) str_alloc);
|
||||
abort ();
|
||||
}
|
||||
if (strcmp (str, want) != 0)
|
||||
{
|
||||
printf ("mpq_get_str wrong (passing NULL)\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" got \"%s\"\n", str);
|
||||
printf (" want \"%s\"\n", want);
|
||||
mpq_trace (" q", q);
|
||||
abort ();
|
||||
}
|
||||
(*__gmp_free_func) (str, strlen (str) + 1);
|
||||
|
||||
str = (char *) (*__gmp_allocate_func) (str_alloc);
|
||||
|
||||
ret = mpq_get_str (str, base, q);
|
||||
if (str != ret)
|
||||
{
|
||||
printf ("mpq_get_str wrong return value (passing non-NULL)\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" got %p\n", (void *) ret);
|
||||
printf (" want %p\n", (void *) str);
|
||||
abort ();
|
||||
}
|
||||
if (strcmp (str, want) != 0)
|
||||
{
|
||||
printf ("mpq_get_str wrong (passing non-NULL)\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" got \"%s\"\n", str);
|
||||
printf (" want \"%s\"\n", want);
|
||||
abort ();
|
||||
}
|
||||
(*__gmp_free_func) (str, str_alloc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
check_all (mpq_srcptr q, int base, const char *want)
|
||||
{
|
||||
char *s;
|
||||
|
||||
check_one (q, base, want);
|
||||
|
||||
s = __gmp_allocate_strdup (want);
|
||||
strtoupper (s);
|
||||
check_one (q, -base, s);
|
||||
(*__gmp_free_func) (s, strlen(s)+1);
|
||||
}
|
||||
|
||||
void
|
||||
check_data (void)
|
||||
{
|
||||
static const struct {
|
||||
int base;
|
||||
const char *num;
|
||||
const char *den;
|
||||
const char *want;
|
||||
} data[] = {
|
||||
{ 10, "0", "1", "0" },
|
||||
{ 10, "1", "1", "1" },
|
||||
|
||||
{ 16, "ffffffff", "1", "ffffffff" },
|
||||
{ 16, "ffffffffffffffff", "1", "ffffffffffffffff" },
|
||||
|
||||
{ 16, "1", "ffffffff", "1/ffffffff" },
|
||||
{ 16, "1", "ffffffffffffffff", "1/ffffffffffffffff" },
|
||||
{ 16, "1", "10000000000000003", "1/10000000000000003" },
|
||||
|
||||
{ 10, "12345678901234567890", "9876543210987654323",
|
||||
"12345678901234567890/9876543210987654323" },
|
||||
};
|
||||
|
||||
mpq_t q;
|
||||
int i;
|
||||
|
||||
mpq_init (q);
|
||||
for (i = 0; i < numberof (data); i++)
|
||||
{
|
||||
mpz_set_str_or_abort (mpq_numref(q), data[i].num, data[i].base);
|
||||
mpz_set_str_or_abort (mpq_denref(q), data[i].den, data[i].base);
|
||||
check_all (q, data[i].base, data[i].want);
|
||||
}
|
||||
mpq_clear (q);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_data ();
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
171
blender-5.2.0/extern/gmp-source/tests/mpq/t-inp_str.c
vendored
Normal file
171
blender-5.2.0/extern/gmp-source/tests/mpq/t-inp_str.c
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
/* Test mpq_inp_str.
|
||||
|
||||
Copyright 2001, 2002 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for unlink */
|
||||
#endif
|
||||
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
#define FILENAME "t-inp_str.tmp"
|
||||
|
||||
|
||||
void
|
||||
check_data (void)
|
||||
{
|
||||
static const struct {
|
||||
const char *inp;
|
||||
int base;
|
||||
const char *want;
|
||||
int want_nread;
|
||||
|
||||
} data[] = {
|
||||
|
||||
{ "0", 10, "0", 1 },
|
||||
{ "0/1", 10, "0", 3 },
|
||||
|
||||
{ "0/", 10, "0", 0 },
|
||||
{ "/123", 10, "0", 0 },
|
||||
{ "blah", 10, "0", 0 },
|
||||
{ "123/blah", 10, "0", 0 },
|
||||
{ "5 /8", 10, "5", 1 },
|
||||
{ "5/ 8", 10, "0", 0 },
|
||||
|
||||
{ "ff", 16, "255", 2 },
|
||||
{ "-ff", 16, "-255", 3 },
|
||||
{ "FF", 16, "255", 2 },
|
||||
{ "-FF", 16, "-255", 3 },
|
||||
|
||||
{ "z", 36, "35", 1 },
|
||||
{ "Z", 36, "35", 1 },
|
||||
|
||||
{ "0x0", 0, "0", 3 },
|
||||
{ "0x10", 0, "16", 4 },
|
||||
{ "-0x0", 0, "0", 4 },
|
||||
{ "-0x10", 0, "-16", 5 },
|
||||
{ "-0x10/5", 0, "-16/5", 7 },
|
||||
|
||||
{ "00", 0, "0", 2 },
|
||||
{ "010", 0, "8", 3 },
|
||||
{ "-00", 0, "0", 3 },
|
||||
{ "-010", 0, "-8", 4 },
|
||||
};
|
||||
|
||||
mpq_t got, want;
|
||||
long ftell_nread;
|
||||
int i, post, j, got_nread;
|
||||
FILE *fp;
|
||||
|
||||
mpq_init (got);
|
||||
mpq_init (want);
|
||||
|
||||
for (i = 0; i < numberof (data); i++)
|
||||
{
|
||||
for (post = 0; post <= 2; post++)
|
||||
{
|
||||
mpq_set_str_or_abort (want, data[i].want, 0);
|
||||
MPQ_CHECK_FORMAT (want);
|
||||
|
||||
fp = fopen (FILENAME, "w+");
|
||||
ASSERT_ALWAYS (fp != NULL);
|
||||
fputs (data[i].inp, fp);
|
||||
for (j = 0; j < post; j++)
|
||||
putc (' ', fp);
|
||||
fflush (fp);
|
||||
ASSERT_ALWAYS (! ferror(fp));
|
||||
|
||||
rewind (fp);
|
||||
got_nread = mpq_inp_str (got, fp, data[i].base);
|
||||
|
||||
if (got_nread != 0)
|
||||
{
|
||||
ftell_nread = ftell (fp);
|
||||
if (got_nread != ftell_nread)
|
||||
{
|
||||
printf ("mpq_inp_str nread wrong\n");
|
||||
printf (" inp \"%s\"\n", data[i].inp);
|
||||
printf (" base %d\n", data[i].base);
|
||||
printf (" got_nread %d\n", got_nread);
|
||||
printf (" ftell_nread %ld\n", ftell_nread);
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
if (post == 0 && data[i].want_nread == strlen(data[i].inp))
|
||||
{
|
||||
int c = getc(fp);
|
||||
if (c != EOF)
|
||||
{
|
||||
printf ("mpq_inp_str didn't read to EOF\n");
|
||||
printf (" inp \"%s\"\n", data[i].inp);
|
||||
printf (" base %d\n", data[i].base);
|
||||
printf (" c '%c' %#x\n", c, c);
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
if (got_nread != data[i].want_nread)
|
||||
{
|
||||
printf ("mpq_inp_str nread wrong\n");
|
||||
printf (" inp \"%s\"\n", data[i].inp);
|
||||
printf (" base %d\n", data[i].base);
|
||||
printf (" got_nread %d\n", got_nread);
|
||||
printf (" want_nread %d\n", data[i].want_nread);
|
||||
abort ();
|
||||
}
|
||||
|
||||
MPQ_CHECK_FORMAT (got);
|
||||
|
||||
if (! mpq_equal (got, want))
|
||||
{
|
||||
printf ("mpq_inp_str wrong result\n");
|
||||
printf (" inp \"%s\"\n", data[i].inp);
|
||||
printf (" base %d\n", data[i].base);
|
||||
mpq_trace (" got ", got);
|
||||
mpq_trace (" want", want);
|
||||
abort ();
|
||||
}
|
||||
|
||||
ASSERT_ALWAYS (fclose (fp) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
mpq_clear (got);
|
||||
mpq_clear (want);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_data ();
|
||||
|
||||
unlink (FILENAME);
|
||||
tests_end ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
60
blender-5.2.0/extern/gmp-source/tests/mpq/t-inv.c
vendored
Normal file
60
blender-5.2.0/extern/gmp-source/tests/mpq/t-inv.c
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Test mpq_inv (and set/get_num/den).
|
||||
|
||||
Copyright 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 "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mpq_t a, b;
|
||||
mpz_t m, n;
|
||||
const char* s = "-420000000000000000000000";
|
||||
|
||||
tests_start ();
|
||||
|
||||
mpq_inits (a, b, (mpq_ptr)0);
|
||||
mpz_inits (m, n, (mpz_ptr)0);
|
||||
|
||||
mpz_set_ui (m, 13);
|
||||
mpq_set_den (a, m);
|
||||
mpz_set_str (m, s, 0);
|
||||
mpq_set_num (a, m);
|
||||
MPQ_CHECK_FORMAT (a);
|
||||
mpq_inv (b, a);
|
||||
MPQ_CHECK_FORMAT (b);
|
||||
mpq_get_num (n, b);
|
||||
ASSERT_ALWAYS (mpz_cmp_si (n, -13) == 0);
|
||||
mpq_neg (b, b);
|
||||
mpq_inv (a, b);
|
||||
MPQ_CHECK_FORMAT (a);
|
||||
mpq_inv (b, b);
|
||||
MPQ_CHECK_FORMAT (b);
|
||||
mpq_get_den (n, b);
|
||||
ASSERT_ALWAYS (mpz_cmp_ui (n, 13) == 0);
|
||||
mpq_get_num (n, a);
|
||||
mpz_add (n, n, m);
|
||||
ASSERT_ALWAYS (mpz_sgn (n) == 0);
|
||||
|
||||
mpq_clears (a, b, (mpq_ptr)0);
|
||||
mpz_clears (m, n, (mpz_ptr)0);
|
||||
|
||||
tests_end ();
|
||||
return 0;
|
||||
}
|
||||
244
blender-5.2.0/extern/gmp-source/tests/mpq/t-md_2exp.c
vendored
Normal file
244
blender-5.2.0/extern/gmp-source/tests/mpq/t-md_2exp.c
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
/* Test mpq_mul_2exp and mpq_div_2exp.
|
||||
|
||||
Copyright 2000, 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
struct pair_t {
|
||||
const char *num;
|
||||
const char *den;
|
||||
};
|
||||
|
||||
void
|
||||
check_random ()
|
||||
{
|
||||
gmp_randstate_ptr rands;
|
||||
mpz_t bs;
|
||||
unsigned long arg_size, size_range;
|
||||
mpq_t q, r;
|
||||
int i;
|
||||
mp_bitcnt_t shift;
|
||||
int reps = 10000;
|
||||
|
||||
rands = RANDS;
|
||||
|
||||
mpz_init (bs);
|
||||
mpq_init (q);
|
||||
mpq_init (r);
|
||||
|
||||
for (i = 0; i < reps; i++)
|
||||
{
|
||||
mpz_urandomb (bs, rands, 32);
|
||||
size_range = mpz_get_ui (bs) % 11 + 2; /* 0..4096 bit operands */
|
||||
|
||||
mpz_urandomb (bs, rands, size_range);
|
||||
arg_size = mpz_get_ui (bs);
|
||||
mpz_rrandomb (mpq_numref (q), rands, arg_size);
|
||||
do
|
||||
{
|
||||
mpz_urandomb (bs, rands, size_range);
|
||||
arg_size = mpz_get_ui (bs);
|
||||
mpz_rrandomb (mpq_denref (q), rands, arg_size);
|
||||
}
|
||||
while (mpz_sgn (mpq_denref (q)) == 0);
|
||||
|
||||
/* We now have a random rational in q, albeit an unnormalised one. The
|
||||
lack of normalisation should not matter here, so let's save the time a
|
||||
gcd would require. */
|
||||
|
||||
mpz_urandomb (bs, rands, 32);
|
||||
shift = mpz_get_ui (bs) % 4096;
|
||||
|
||||
mpq_mul_2exp (r, q, shift);
|
||||
|
||||
if (mpq_cmp (r, q) < 0)
|
||||
{
|
||||
printf ("mpq_mul_2exp wrong on random\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
mpq_div_2exp (r, r, shift);
|
||||
|
||||
if (mpq_cmp (r, q) != 0)
|
||||
{
|
||||
printf ("mpq_mul_2exp or mpq_div_2exp wrong on random\n");
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
mpq_clear (q);
|
||||
mpq_clear (r);
|
||||
mpz_clear (bs);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
static const 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) (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;
|
||||
|
||||
tests_start ();
|
||||
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check_random ();
|
||||
|
||||
mpq_clear (sep);
|
||||
mpq_clear (got);
|
||||
mpq_clear (want);
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
169
blender-5.2.0/extern/gmp-source/tests/mpq/t-set_f.c
vendored
Normal file
169
blender-5.2.0/extern/gmp-source/tests/mpq/t-set_f.c
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
/* Test mpq_set_f.
|
||||
|
||||
Copyright 2000, 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
#if GMP_NAIL_BITS == 0
|
||||
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;
|
||||
|
||||
tests_start ();
|
||||
|
||||
mpf_init2 (f, 1024L);
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mpf_clear (f);
|
||||
mpq_clear (got);
|
||||
mpz_clear (want_num);
|
||||
mpz_clear (want_den);
|
||||
|
||||
tests_end ();
|
||||
#endif
|
||||
exit (0);
|
||||
}
|
||||
102
blender-5.2.0/extern/gmp-source/tests/mpq/t-set_str.c
vendored
Normal file
102
blender-5.2.0/extern/gmp-source/tests/mpq/t-set_str.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Test mpq_set_str.
|
||||
|
||||
Copyright 2001 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
void
|
||||
check_one (mpq_srcptr want, int base, const char *str)
|
||||
{
|
||||
mpq_t got;
|
||||
|
||||
MPQ_CHECK_FORMAT (want);
|
||||
mp_trace_base = base;
|
||||
|
||||
mpq_init (got);
|
||||
|
||||
if (mpq_set_str (got, str, base) != 0)
|
||||
{
|
||||
printf ("mpq_set_str unexpectedly failed\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" str \"%s\"\n", str);
|
||||
abort ();
|
||||
}
|
||||
MPQ_CHECK_FORMAT (got);
|
||||
|
||||
if (! mpq_equal (got, want))
|
||||
{
|
||||
printf ("mpq_set_str wrong\n");
|
||||
printf (" base %d\n", base);
|
||||
printf (" str \"%s\"\n", str);
|
||||
mpq_trace ("got ", got);
|
||||
mpq_trace ("want", want);
|
||||
abort ();
|
||||
}
|
||||
|
||||
mpq_clear (got);
|
||||
}
|
||||
|
||||
void
|
||||
check_samples (void)
|
||||
{
|
||||
mpq_t q;
|
||||
|
||||
mpq_init (q);
|
||||
|
||||
mpq_set_ui (q, 0L, 1L);
|
||||
check_one (q, 10, "0");
|
||||
check_one (q, 10, "0/1");
|
||||
check_one (q, 10, "0 / 1");
|
||||
check_one (q, 0, "0x0/ 1");
|
||||
check_one (q, 0, "0x0/ 0x1");
|
||||
check_one (q, 0, "0 / 0x1");
|
||||
|
||||
check_one (q, 10, "-0");
|
||||
check_one (q, 10, "-0/1");
|
||||
check_one (q, 10, "-0 / 1");
|
||||
check_one (q, 0, "-0x0/ 1");
|
||||
check_one (q, 0, "-0x0/ 0x1");
|
||||
check_one (q, 0, "-0 / 0x1");
|
||||
|
||||
mpq_set_ui (q, 255L, 256L);
|
||||
check_one (q, 10, "255/256");
|
||||
check_one (q, 0, "0xFF/0x100");
|
||||
check_one (q, 16, "FF/100");
|
||||
|
||||
mpq_neg (q, q);
|
||||
check_one (q, 10, "-255/256");
|
||||
check_one (q, 0, "-0xFF/0x100");
|
||||
check_one (q, 16, "-FF/100");
|
||||
|
||||
mpq_clear (q);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
tests_start ();
|
||||
|
||||
check_samples ();
|
||||
|
||||
tests_end ();
|
||||
exit (0);
|
||||
}
|
||||
Reference in New Issue
Block a user