diff options
-rw-r--r-- | mpz/tests/t-mod2.c | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/mpz/tests/t-mod2.c b/mpz/tests/t-mod2.c deleted file mode 100644 index 54e6e9d43..000000000 --- a/mpz/tests/t-mod2.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Exercise mpz_mod2 and related macros. They're pretty simple, but it's - good to at least give them a run. */ - -/* -Copyright (C) 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library 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" - - -struct { - char *s; - int odd, even; - unsigned long mod2, mod4, mod8; -} data[] = { - { "0", 0, 1, 0, 0, 0 }, - { "1", 1, 0, 1, 1, 1 }, - { "2", 0, 1, 0, 2, 2 }, - { "3", 1, 0, 1, 3, 3 }, - { "4", 0, 1, 0, 0, 4 }, - { "5", 1, 0, 1, 1, 5 }, - { "6", 0, 1, 0, 2, 6 }, - { "7", 1, 0, 1, 3, 7 }, - { "8", 0, 1, 0, 0, 0 }, - { "9", 1, 0, 1, 1, 1 }, - { "10", 0, 1, 0, 2, 2 }, - { "11", 1, 0, 1, 3, 3 }, - { "12", 0, 1, 0, 0, 4 }, - { "13", 1, 0, 1, 1, 5 }, - { "14", 0, 1, 0, 2, 6 }, - { "15", 1, 0, 1, 3, 7 }, - - { "-15", 1, 0, 1, 1, 1 }, - { "-14", 0, 1, 0, 2, 2 }, - { "-13", 1, 0, 1, 3, 3 }, - { "-12", 0, 1, 0, 0, 4 }, - { "-11", 1, 0, 1, 1, 5 }, - { "-10", 0, 1, 0, 2, 6 }, - { "-9", 1, 0, 1, 3, 7 }, - { "-8", 0, 1, 0, 0, 0 }, - { "-7", 1, 0, 1, 1, 1 }, - { "-6", 0, 1, 0, 2, 2 }, - { "-5", 1, 0, 1, 3, 3 }, - { "-4", 0, 1, 0, 0, 4 }, - { "-3", 1, 0, 1, 1, 5 }, - { "-2", 0, 1, 0, 2, 6 }, - { "-1", 1, 0, 1, 3, 7 }, - - { "0x1000000000000000000000000000000000000000000000000000", 0, 1, 0, 0, 0 }, - { "0x1000000000000000000000000000000000000000000000000001", 1, 0, 1, 1, 1 }, - { "0x1000000000000000000000000000000000000000000000000002", 0, 1, 0, 2, 2 }, - { "0x1000000000000000000000000000000000000000000000000003", 1, 0, 1, 3, 3 }, - { "0x1000000000000000000000000000000000000000000000000004", 0, 1, 0, 0, 4 }, - { "0x1000000000000000000000000000000000000000000000000005", 1, 0, 1, 1, 5 }, - { "0x1000000000000000000000000000000000000000000000000006", 0, 1, 0, 2, 6 }, - { "0x1000000000000000000000000000000000000000000000000007", 1, 0, 1, 3, 7 }, - { "0x1000000000000000000000000000000000000000000000000008", 0, 1, 0, 0, 0 }, - { "0x1000000000000000000000000000000000000000000000000009", 1, 0, 1, 1, 1 }, - { "0x100000000000000000000000000000000000000000000000000A", 0, 1, 0, 2, 2 }, - { "0x100000000000000000000000000000000000000000000000000B", 1, 0, 1, 3, 3 }, - { "0x100000000000000000000000000000000000000000000000000C", 0, 1, 0, 0, 4 }, - { "0x100000000000000000000000000000000000000000000000000D", 1, 0, 1, 1, 5 }, - { "0x100000000000000000000000000000000000000000000000000E", 0, 1, 0, 2, 6 }, - { "0x100000000000000000000000000000000000000000000000000F", 1, 0, 1, 3, 7 }, - - { "-0x100000000000000000000000000000000000000000000000000F", 1, 0, 1, 1, 1 }, - { "-0x100000000000000000000000000000000000000000000000000E", 0, 1, 0, 2, 2 }, - { "-0x100000000000000000000000000000000000000000000000000D", 1, 0, 1, 3, 3 }, - { "-0x100000000000000000000000000000000000000000000000000C", 0, 1, 0, 0, 4 }, - { "-0x100000000000000000000000000000000000000000000000000B", 1, 0, 1, 1, 5 }, - { "-0x100000000000000000000000000000000000000000000000000A", 0, 1, 0, 2, 6 }, - { "-0x1000000000000000000000000000000000000000000000000009", 1, 0, 1, 3, 7 }, - { "-0x1000000000000000000000000000000000000000000000000008", 0, 1, 0, 0, 0 }, - { "-0x1000000000000000000000000000000000000000000000000007", 1, 0, 1, 1, 1 }, - { "-0x1000000000000000000000000000000000000000000000000006", 0, 1, 0, 2, 2 }, - { "-0x1000000000000000000000000000000000000000000000000005", 1, 0, 1, 3, 3 }, - { "-0x1000000000000000000000000000000000000000000000000004", 0, 1, 0, 0, 4 }, - { "-0x1000000000000000000000000000000000000000000000000003", 1, 0, 1, 1, 5 }, - { "-0x1000000000000000000000000000000000000000000000000002", 0, 1, 0, 2, 6 }, - { "-0x1000000000000000000000000000000000000000000000000001", 1, 0, 1, 3, 7 }, - -}; - - -#define numberof(x) (sizeof (x) / sizeof ((x)[0])) - -#define ERROR(name) \ - { \ - printf ("%s wrong at data[%d]\n", name, i); \ - abort(); \ - } - -int -main (void) -{ - mpz_t n; - int i; - - mpz_init (n); - for (i = 0; i < numberof (data); i++) - { - mpz_set_str (n, data[i].s, 0); - - if ((mpz_odd_p (n) != 0) != data[i].odd) - ERROR ("mpz_odd_p"); - - if ((mpz_even_p (n) != 0) != data[i].even) - ERROR ("mpz_even_p"); - - if (mpz_mod2 (n) != data[i].mod2) - ERROR ("mpz_mod2"); - - if (mpz_mod4 (n) != data[i].mod4) - ERROR ("mpz_mod4"); - - if (mpz_mod8 (n) != data[i].mod8) - ERROR ("mpz_mod8"); - } - - mpz_clear (n); - return 0; -} |