Annotation of OpenXM_contrib/gmp/mpbsd/tests/t-misc.c, Revision 1.1
1.1 ! maekawa 1: /* Exercise various mpbsd functions. */
! 2:
! 3: /*
! 4: Copyright (C) 2000 Free Software Foundation, Inc.
! 5:
! 6: This file is part of the GNU MP Library.
! 7:
! 8: The GNU MP Library is free software; you can redistribute it and/or modify
! 9: it under the terms of the GNU Lesser General Public License as published by
! 10: the Free Software Foundation; either version 2.1 of the License, or (at your
! 11: option) any later version.
! 12:
! 13: The GNU MP Library is distributed in the hope that it will be useful, but
! 14: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 15: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
! 16: License for more details.
! 17:
! 18: You should have received a copy of the GNU Lesser General Public License
! 19: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
! 20: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! 21: MA 02111-1307, USA.
! 22: */
! 23:
! 24: #include <stdio.h>
! 25: #include "gmp.h"
! 26: #include "gmp-impl.h"
! 27: #include "mp.h"
! 28:
! 29: #define SGN(x) ((x) < 0 ? -1 : (x) == 0 ? 0 : 1)
! 30:
! 31:
! 32: void
! 33: check_itom (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: { SHORT_MAX, 1, SHORT_MAX },
! 46: { -SHORT_MAX, -1, SHORT_MAX },
! 47:
! 48: { SHORT_HIGHBIT, -1, USHORT_HIGHBIT },
! 49: };
! 50:
! 51: MINT *m;
! 52: int i;
! 53:
! 54: for (i = 0; i < numberof (data); i++)
! 55: {
! 56: m = itom (data[i].m);
! 57: if (m->_mp_size != data[i].want_size
! 58: || (m->_mp_size != 0 && m->_mp_d[0] != data[i].want_limb))
! 59: {
! 60: printf ("itom wrong on data[%d]\n", i);
! 61: abort();
! 62: }
! 63: mfree (m);
! 64: }
! 65: }
! 66:
! 67:
! 68: int
! 69: main (void)
! 70: {
! 71: check_itom ();
! 72:
! 73: exit (0);
! 74: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>