Annotation of OpenXM_contrib/gmp/tests/mpf/t-set_si.c, Revision 1.1.1.1
1.1 ohara 1: /* Test mpf_set_si and mpf_init_set_si.
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 "tests.h"
27:
28: void
29: check_data (void)
30: {
31: static const struct {
32: long x;
33: mp_size_t want_size;
34: mp_limb_t want_limb;
35: } data[] = {
36:
37: { 0L, 0 },
38: { 1L, 1, 1 },
39: { -1L, -1, 1 },
40:
41: { LONG_MAX, 1, LONG_MAX },
42: { -LONG_MAX, -1, LONG_MAX },
43:
44: { LONG_HIGHBIT, -1, ULONG_HIGHBIT },
45: };
46:
47: mpf_t x;
48: int i;
49:
50: for (i = 0; i < numberof (data); i++)
51: {
52: mpf_init (x);
53: mpf_set_si (x, data[i].x);
54: MPF_CHECK_FORMAT (x);
55: if (x->_mp_size != data[i].want_size
56: || (x->_mp_size != 0
57: && (x->_mp_d[0] != data[i].want_limb
58: || x->_mp_exp != 1)))
59: {
60: printf ("mpf_set_si wrong on data[%d]\n", i);
61: abort();
62: }
63: mpf_clear (x);
64:
65: mpf_init_set_si (x, data[i].x);
66: MPF_CHECK_FORMAT (x);
67: if (x->_mp_size != data[i].want_size
68: || (x->_mp_size != 0
69: && (x->_mp_d[0] != data[i].want_limb
70: || x->_mp_exp != 1)))
71: {
72: printf ("mpf_init_set_si wrong on data[%d]\n", i);
73: abort();
74: }
75: mpf_clear (x);
76: }
77: }
78:
79: int
80: main (void)
81: {
82: #if GMP_NAIL_BITS == 0 /* bogus test criteria cause nails to fail */
83: tests_start ();
84:
85: check_data ();
86:
87: tests_end ();
88: #endif
89: exit (0);
90: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>