Home | History | Annotate | Line # | Download | only in tests
      1  1.1  mrg /* tpl_gmp.c --  Helper functions for mpfr data.
      2  1.1  mrg 
      3  1.1  mrg Copyright (C) 2012, 2013 INRIA
      4  1.1  mrg 
      5  1.1  mrg This file is part of GNU MPC.
      6  1.1  mrg 
      7  1.1  mrg GNU MPC is free software; you can redistribute it and/or modify it under
      8  1.1  mrg the terms of the GNU Lesser General Public License as published by the
      9  1.1  mrg Free Software Foundation; either version 3 of the License, or (at your
     10  1.1  mrg option) any later version.
     11  1.1  mrg 
     12  1.1  mrg GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
     13  1.1  mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     14  1.1  mrg FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
     15  1.1  mrg more details.
     16  1.1  mrg 
     17  1.1  mrg You should have received a copy of the GNU Lesser General Public License
     18  1.1  mrg along with this program. If not, see http://www.gnu.org/licenses/ .
     19  1.1  mrg */
     20  1.1  mrg 
     21  1.1  mrg #include "mpc-tests.h"
     22  1.1  mrg 
     23  1.1  mrg void
     24  1.1  mrg tpl_read_mpz (mpc_datafile_context_t* datafile_context, mpz_t mpz)
     25  1.1  mrg {
     26  1.1  mrg    if (datafile_context->nextchar == EOF) {
     27  1.1  mrg       printf ("Error: Unexpected EOF when reading mpz "
     28  1.1  mrg               "in file '%s' line %lu\n",
     29  1.1  mrg               datafile_context->pathname, datafile_context->line_number);
     30  1.1  mrg       exit (1);
     31  1.1  mrg    }
     32  1.1  mrg    ungetc (datafile_context->nextchar, datafile_context->fd);
     33  1.1  mrg    if (mpz_inp_str (mpz, datafile_context->fd, 0) == 0) {
     34  1.1  mrg       printf ("Error: Impossible to read mpz "
     35  1.1  mrg               "in file '%s' line %lu\n",
     36  1.1  mrg               datafile_context->pathname, datafile_context->line_number);
     37  1.1  mrg       exit (1);
     38  1.1  mrg    }
     39  1.1  mrg    datafile_context->nextchar = getc (datafile_context->fd);
     40  1.1  mrg    tpl_skip_whitespace_comments (datafile_context);
     41  1.1  mrg }
     42  1.1  mrg 
     43  1.1  mrg int
     44  1.1  mrg tpl_same_mpz_value (mpz_ptr z1, mpz_ptr z2)
     45  1.1  mrg {
     46  1.1  mrg    return mpz_cmp (z1, z2) == 0;
     47  1.1  mrg }
     48  1.1  mrg 
     49  1.1  mrg void
     50  1.1  mrg tpl_copy_mpz (mpz_ptr dest, mpz_srcptr src)
     51  1.1  mrg {
     52  1.1  mrg   mpz_set (dest, src);
     53  1.1  mrg }
     54