[BACK]Return to t-itom.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / tests / mpbsd

Annotation of OpenXM_contrib/gmp/tests/mpbsd/t-itom.c, Revision 1.1.1.1

1.1       ohara       1: /* Test itom.
                      2:
                      3: Copyright 2000, 2001 Free Software Foundation, Inc.
                      4:
                      5: This file is part of the GNU MP Library.
                      6:
                      7: The GNU MP Library is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU Lesser General Public License as published by
                      9: the Free Software Foundation; either version 2.1 of the License, or (at your
                     10: option) any later version.
                     11:
                     12: The GNU MP Library is distributed in the hope that it will be useful, but
                     13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
                     15: License for more details.
                     16:
                     17: You should have received a copy of the GNU Lesser General Public License
                     18: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     20: MA 02111-1307, USA. */
                     21:
                     22: #include <stdio.h>
                     23: #include <stdlib.h>
                     24: #include "gmp.h"
                     25: #include "gmp-impl.h"
                     26: #include "mp.h"
                     27: #include "tests.h"
                     28:
                     29: #define SGN(x)       ((x) < 0 ? -1 : (x) == 0 ? 0 : 1)
                     30:
                     31:
                     32: void
                     33: check_data (void)
                     34: {
                     35:   static const struct {
                     36:     short      m;
                     37:     mp_size_t  want_size;
                     38:     mp_limb_t  want_limb;
                     39:   } data[] = {
                     40:
                     41:     {  0L,  0 },
                     42:     {  1L,  1, 1 },
                     43:     { -1L, -1, 1 },
                     44:
                     45:     {  SHRT_MAX,  1,  SHRT_MAX },
                     46:     { -SHRT_MAX, -1,  SHRT_MAX },
                     47:     {  SHRT_MIN, -1, -SHRT_MIN },
                     48:   };
                     49:
                     50:   MINT  *m;
                     51:   int   i;
                     52:
                     53:   for (i = 0; i < numberof (data); i++)
                     54:     {
                     55:       m = itom (data[i].m);
                     56:       if (m->_mp_size != data[i].want_size
                     57:           || (m->_mp_size != 0 && m->_mp_d[0] != data[i].want_limb))
                     58:         {
                     59:           printf ("itom wrong on data[%d]\n", i);
                     60:           abort();
                     61:         }
                     62:       mfree (m);
                     63:     }
                     64: }
                     65:
                     66:
                     67: int
                     68: main (void)
                     69: {
                     70:   tests_start ();
                     71:
                     72:   check_data ();
                     73:
                     74:   tests_end ();
                     75:   exit (0);
                     76: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>