Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame^] | 1 | /* |
| 2 | |
| 3 | Copyright 2012, Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of the GNU MP Library test suite. |
| 6 | |
| 7 | The GNU MP Library test suite is free software; you can redistribute it |
| 8 | and/or modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 3 of the License, |
| 10 | or (at your option) any later version. |
| 11 | |
| 12 | The GNU MP Library test suite is distributed in the hope that it will be |
| 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 15 | Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License along with |
| 18 | the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | #include "testutils.h" |
| 24 | |
| 25 | #define MAXBITS 400 |
| 26 | #define COUNT 10000 |
| 27 | |
| 28 | void |
| 29 | testmain (int argc, char **argv) |
| 30 | { |
| 31 | unsigned i; |
| 32 | mpz_t a, b, res, ref; |
| 33 | |
| 34 | mpz_init (a); |
| 35 | mpz_init (b); |
| 36 | mpz_init (res); |
| 37 | mpz_init (ref); |
| 38 | |
| 39 | for (i = 0; i < COUNT; i++) |
| 40 | { |
| 41 | mini_random_op3 (OP_ADD, MAXBITS, a, b, ref); |
| 42 | mpz_add (res, a, b); |
| 43 | if (mpz_cmp (res, ref)) |
| 44 | { |
| 45 | fprintf (stderr, "mpz_add failed:\n"); |
| 46 | dump ("a", a); |
| 47 | dump ("b", b); |
| 48 | dump ("r", res); |
| 49 | dump ("ref", ref); |
| 50 | abort (); |
| 51 | } |
| 52 | } |
| 53 | mpz_clear (a); |
| 54 | mpz_clear (b); |
| 55 | mpz_clear (res); |
| 56 | mpz_clear (ref); |
| 57 | } |