tfpif.c revision 1.1.1.1.2.2 1 1.1.1.1.2.2 pgoyette /* Test file for mpfr_fpif.
2 1.1.1.1.2.2 pgoyette
3 1.1.1.1.2.2 pgoyette Copyright 2012-2018 Free Software Foundation, Inc.
4 1.1.1.1.2.2 pgoyette Contributed by Olivier Demengeon.
5 1.1.1.1.2.2 pgoyette
6 1.1.1.1.2.2 pgoyette This file is part of the GNU MPFR Library.
7 1.1.1.1.2.2 pgoyette
8 1.1.1.1.2.2 pgoyette The GNU MPFR Library is free software; you can redistribute it and/or modify
9 1.1.1.1.2.2 pgoyette it under the terms of the GNU Lesser General Public License as published by
10 1.1.1.1.2.2 pgoyette the Free Software Foundation; either version 3 of the License, or (at your
11 1.1.1.1.2.2 pgoyette option) any later version.
12 1.1.1.1.2.2 pgoyette
13 1.1.1.1.2.2 pgoyette The GNU MPFR Library is distributed in the hope that it will be useful, but
14 1.1.1.1.2.2 pgoyette WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 1.1.1.1.2.2 pgoyette or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 1.1.1.1.2.2 pgoyette License for more details.
17 1.1.1.1.2.2 pgoyette
18 1.1.1.1.2.2 pgoyette You should have received a copy of the GNU Lesser General Public License
19 1.1.1.1.2.2 pgoyette along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
20 1.1.1.1.2.2 pgoyette http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 1.1.1.1.2.2 pgoyette 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 1.1.1.1.2.2 pgoyette
23 1.1.1.1.2.2 pgoyette #include "mpfr-test.h"
24 1.1.1.1.2.2 pgoyette
25 1.1.1.1.2.2 pgoyette #define FILE_NAME_RW "tfpif_rw.dat" /* temporary name (written then read) */
26 1.1.1.1.2.2 pgoyette #define FILE_NAME_R "tfpif_r1.dat" /* fixed file name (read only) */
27 1.1.1.1.2.2 pgoyette #define FILE_NAME_R2 "tfpif_r2.dat" /* fixed file name (read only) with a
28 1.1.1.1.2.2 pgoyette precision > MPFR_PREC_MAX */
29 1.1.1.1.2.2 pgoyette
30 1.1.1.1.2.2 pgoyette static void
31 1.1.1.1.2.2 pgoyette doit (int argc, char *argv[], mpfr_prec_t p1, mpfr_prec_t p2)
32 1.1.1.1.2.2 pgoyette {
33 1.1.1.1.2.2 pgoyette char *filenameCompressed = FILE_NAME_RW;
34 1.1.1.1.2.2 pgoyette char *data = FILE_NAME_R;
35 1.1.1.1.2.2 pgoyette int status;
36 1.1.1.1.2.2 pgoyette FILE *fh;
37 1.1.1.1.2.2 pgoyette mpfr_t x[9];
38 1.1.1.1.2.2 pgoyette mpfr_t y;
39 1.1.1.1.2.2 pgoyette int i, neg;
40 1.1.1.1.2.2 pgoyette long pos;
41 1.1.1.1.2.2 pgoyette
42 1.1.1.1.2.2 pgoyette mpfr_init2 (x[0], p1);
43 1.1.1.1.2.2 pgoyette mpfr_init2 (x[8], p1);
44 1.1.1.1.2.2 pgoyette mpfr_inits2 (p2, x[1], x[2], x[3], x[4], x[5], x[6], x[7], (mpfr_ptr) 0);
45 1.1.1.1.2.2 pgoyette mpfr_set_str1 (x[0], "45.2564215000000018562786863185465335845947265625");
46 1.1.1.1.2.2 pgoyette mpfr_set_str1 (x[1], "45.2564215000000018562786863185465335845947265625");
47 1.1.1.1.2.2 pgoyette mpfr_set_str1 (x[2], "45.2564215000000018562786863185465335845947265625");
48 1.1.1.1.2.2 pgoyette mpfr_set_exp (x[2], -48000);
49 1.1.1.1.2.2 pgoyette mpfr_set_inf (x[3], 1);
50 1.1.1.1.2.2 pgoyette mpfr_set_zero (x[4], 1);
51 1.1.1.1.2.2 pgoyette mpfr_set_nan (x[5]);
52 1.1.1.1.2.2 pgoyette mpfr_set_ui (x[6], 104348, MPFR_RNDN);
53 1.1.1.1.2.2 pgoyette mpfr_set_ui (x[7], 33215, MPFR_RNDN);
54 1.1.1.1.2.2 pgoyette mpfr_div (x[8], x[6], x[7], MPFR_RNDN);
55 1.1.1.1.2.2 pgoyette mpfr_div (x[6], x[6], x[7], MPFR_RNDN);
56 1.1.1.1.2.2 pgoyette
57 1.1.1.1.2.2 pgoyette /* we first write to file FILE_NAME_RW the numbers x[i] */
58 1.1.1.1.2.2 pgoyette fh = fopen (filenameCompressed, "w");
59 1.1.1.1.2.2 pgoyette if (fh == NULL)
60 1.1.1.1.2.2 pgoyette {
61 1.1.1.1.2.2 pgoyette printf ("Failed to open for writing %s\n", filenameCompressed);
62 1.1.1.1.2.2 pgoyette exit (1);
63 1.1.1.1.2.2 pgoyette }
64 1.1.1.1.2.2 pgoyette
65 1.1.1.1.2.2 pgoyette for (neg = 0; neg < 2; neg++)
66 1.1.1.1.2.2 pgoyette for (i = 0; i < 9; i++)
67 1.1.1.1.2.2 pgoyette {
68 1.1.1.1.2.2 pgoyette if (neg)
69 1.1.1.1.2.2 pgoyette MPFR_CHANGE_SIGN (x[i]);
70 1.1.1.1.2.2 pgoyette
71 1.1.1.1.2.2 pgoyette status = mpfr_fpif_export (fh, x[i]);
72 1.1.1.1.2.2 pgoyette if (status != 0)
73 1.1.1.1.2.2 pgoyette {
74 1.1.1.1.2.2 pgoyette fclose (fh);
75 1.1.1.1.2.2 pgoyette printf ("Failed to export number %d, neg=%d\n", i, neg);
76 1.1.1.1.2.2 pgoyette exit (1);
77 1.1.1.1.2.2 pgoyette }
78 1.1.1.1.2.2 pgoyette
79 1.1.1.1.2.2 pgoyette if (neg)
80 1.1.1.1.2.2 pgoyette MPFR_CHANGE_SIGN (x[i]);
81 1.1.1.1.2.2 pgoyette }
82 1.1.1.1.2.2 pgoyette
83 1.1.1.1.2.2 pgoyette fclose (fh);
84 1.1.1.1.2.2 pgoyette
85 1.1.1.1.2.2 pgoyette /* we then read back FILE_NAME_RW and check we get the same numbers x[i] */
86 1.1.1.1.2.2 pgoyette fh = fopen (filenameCompressed, "r");
87 1.1.1.1.2.2 pgoyette if (fh == NULL)
88 1.1.1.1.2.2 pgoyette {
89 1.1.1.1.2.2 pgoyette printf ("Failed to open for reading %s\n", filenameCompressed);
90 1.1.1.1.2.2 pgoyette exit (1);
91 1.1.1.1.2.2 pgoyette }
92 1.1.1.1.2.2 pgoyette
93 1.1.1.1.2.2 pgoyette for (neg = 0; neg < 2; neg++)
94 1.1.1.1.2.2 pgoyette for (i = 0; i < 9; i++)
95 1.1.1.1.2.2 pgoyette {
96 1.1.1.1.2.2 pgoyette mpfr_prec_t px, py;
97 1.1.1.1.2.2 pgoyette
98 1.1.1.1.2.2 pgoyette if (neg)
99 1.1.1.1.2.2 pgoyette MPFR_CHANGE_SIGN (x[i]);
100 1.1.1.1.2.2 pgoyette
101 1.1.1.1.2.2 pgoyette mpfr_init2 (y, 2);
102 1.1.1.1.2.2 pgoyette /* Set the sign bit of y to the opposite of the expected one.
103 1.1.1.1.2.2 pgoyette Thus, if mpfr_fpif_import forgets to set the sign, this will
104 1.1.1.1.2.2 pgoyette be detected. */
105 1.1.1.1.2.2 pgoyette MPFR_SET_SIGN (y, - MPFR_SIGN (x[i]));
106 1.1.1.1.2.2 pgoyette mpfr_fpif_import (y, fh);
107 1.1.1.1.2.2 pgoyette px = mpfr_get_prec (x[i]);
108 1.1.1.1.2.2 pgoyette py = mpfr_get_prec (y);
109 1.1.1.1.2.2 pgoyette if (px != py)
110 1.1.1.1.2.2 pgoyette {
111 1.1.1.1.2.2 pgoyette printf ("doit failed on written number %d, neg=%d:"
112 1.1.1.1.2.2 pgoyette " bad precision\n", i, neg);
113 1.1.1.1.2.2 pgoyette printf ("expected %ld\n", (long) px);
114 1.1.1.1.2.2 pgoyette printf ("got %ld\n", (long) py);
115 1.1.1.1.2.2 pgoyette exit (1);
116 1.1.1.1.2.2 pgoyette }
117 1.1.1.1.2.2 pgoyette if (MPFR_SIGN (x[i]) != MPFR_SIGN (y))
118 1.1.1.1.2.2 pgoyette {
119 1.1.1.1.2.2 pgoyette printf ("doit failed on written number %d, neg=%d:"
120 1.1.1.1.2.2 pgoyette " bad sign\n", i, neg);
121 1.1.1.1.2.2 pgoyette printf ("expected %d\n", (int) MPFR_SIGN (x[i]));
122 1.1.1.1.2.2 pgoyette printf ("got %d\n", (int) MPFR_SIGN (y));
123 1.1.1.1.2.2 pgoyette exit (1);
124 1.1.1.1.2.2 pgoyette }
125 1.1.1.1.2.2 pgoyette if (! SAME_VAL (x[i], y))
126 1.1.1.1.2.2 pgoyette {
127 1.1.1.1.2.2 pgoyette printf ("doit failed on written number %d, neg=%d\n", i, neg);
128 1.1.1.1.2.2 pgoyette printf ("expected "); mpfr_dump (x[i]);
129 1.1.1.1.2.2 pgoyette printf ("got "); mpfr_dump (y);
130 1.1.1.1.2.2 pgoyette exit (1);
131 1.1.1.1.2.2 pgoyette }
132 1.1.1.1.2.2 pgoyette mpfr_clear (y);
133 1.1.1.1.2.2 pgoyette
134 1.1.1.1.2.2 pgoyette if (neg)
135 1.1.1.1.2.2 pgoyette MPFR_CHANGE_SIGN (x[i]);
136 1.1.1.1.2.2 pgoyette }
137 1.1.1.1.2.2 pgoyette fclose (fh);
138 1.1.1.1.2.2 pgoyette
139 1.1.1.1.2.2 pgoyette /* we do the same for the fixed file FILE_NAME_R, this ensures
140 1.1.1.1.2.2 pgoyette we get same results with different word size or endianness */
141 1.1.1.1.2.2 pgoyette fh = src_fopen (data, "r");
142 1.1.1.1.2.2 pgoyette if (fh == NULL)
143 1.1.1.1.2.2 pgoyette {
144 1.1.1.1.2.2 pgoyette printf ("Failed to open for reading %s in srcdir\n", data);
145 1.1.1.1.2.2 pgoyette exit (1);
146 1.1.1.1.2.2 pgoyette }
147 1.1.1.1.2.2 pgoyette
148 1.1.1.1.2.2 pgoyette /* the fixed file FILE_NAME_R assumes p1=130 and p2=2048 */
149 1.1.1.1.2.2 pgoyette for (i = 0; i < 9 && (p1 == 130 && p2 == 2048); i++)
150 1.1.1.1.2.2 pgoyette {
151 1.1.1.1.2.2 pgoyette mpfr_prec_t px, py;
152 1.1.1.1.2.2 pgoyette
153 1.1.1.1.2.2 pgoyette mpfr_init2 (y, 2);
154 1.1.1.1.2.2 pgoyette /* Set the sign bit of y to the opposite of the expected one.
155 1.1.1.1.2.2 pgoyette Thus, if mpfr_fpif_import forgets to set the sign, this will
156 1.1.1.1.2.2 pgoyette be detected. */
157 1.1.1.1.2.2 pgoyette MPFR_SET_SIGN (y, - MPFR_SIGN (x[i]));
158 1.1.1.1.2.2 pgoyette pos = ftell (fh);
159 1.1.1.1.2.2 pgoyette mpfr_fpif_import (y, fh);
160 1.1.1.1.2.2 pgoyette px = mpfr_get_prec (x[i]);
161 1.1.1.1.2.2 pgoyette py = mpfr_get_prec (y);
162 1.1.1.1.2.2 pgoyette if (px != py)
163 1.1.1.1.2.2 pgoyette {
164 1.1.1.1.2.2 pgoyette printf ("doit failed on data number %d, neg=%d:"
165 1.1.1.1.2.2 pgoyette " bad precision\n", i, neg);
166 1.1.1.1.2.2 pgoyette printf ("expected %ld\n", (long) px);
167 1.1.1.1.2.2 pgoyette printf ("got %ld\n", (long) py);
168 1.1.1.1.2.2 pgoyette exit (1);
169 1.1.1.1.2.2 pgoyette }
170 1.1.1.1.2.2 pgoyette if (MPFR_SIGN (x[i]) != MPFR_SIGN (y))
171 1.1.1.1.2.2 pgoyette {
172 1.1.1.1.2.2 pgoyette printf ("doit failed on data number %d, neg=%d:"
173 1.1.1.1.2.2 pgoyette " bad sign\n", i, neg);
174 1.1.1.1.2.2 pgoyette printf ("expected %d\n", (int) MPFR_SIGN (x[i]));
175 1.1.1.1.2.2 pgoyette printf ("got %d\n", (int) MPFR_SIGN (y));
176 1.1.1.1.2.2 pgoyette exit (1);
177 1.1.1.1.2.2 pgoyette }
178 1.1.1.1.2.2 pgoyette if (! SAME_VAL (x[i], y))
179 1.1.1.1.2.2 pgoyette {
180 1.1.1.1.2.2 pgoyette printf ("doit failed on data number %d, neg=%d, at offset 0x%lx\n",
181 1.1.1.1.2.2 pgoyette i, neg, (unsigned long) pos);
182 1.1.1.1.2.2 pgoyette printf ("expected "); mpfr_dump (x[i]);
183 1.1.1.1.2.2 pgoyette printf ("got "); mpfr_dump (y);
184 1.1.1.1.2.2 pgoyette exit (1);
185 1.1.1.1.2.2 pgoyette }
186 1.1.1.1.2.2 pgoyette mpfr_clear (y);
187 1.1.1.1.2.2 pgoyette }
188 1.1.1.1.2.2 pgoyette fclose (fh);
189 1.1.1.1.2.2 pgoyette
190 1.1.1.1.2.2 pgoyette for (i = 0; i < 9; i++)
191 1.1.1.1.2.2 pgoyette mpfr_clear (x[i]);
192 1.1.1.1.2.2 pgoyette
193 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
194 1.1.1.1.2.2 pgoyette }
195 1.1.1.1.2.2 pgoyette
196 1.1.1.1.2.2 pgoyette static void
197 1.1.1.1.2.2 pgoyette check_bad (void)
198 1.1.1.1.2.2 pgoyette {
199 1.1.1.1.2.2 pgoyette char *filenameCompressed = FILE_NAME_RW;
200 1.1.1.1.2.2 pgoyette int status;
201 1.1.1.1.2.2 pgoyette FILE *fh;
202 1.1.1.1.2.2 pgoyette mpfr_t x;
203 1.1.1.1.2.2 pgoyette unsigned char badData[6][2] =
204 1.1.1.1.2.2 pgoyette { { 7, 0 }, { 16, 0 }, { 23, 118 }, { 23, 95 }, { 23, 127 }, { 23, 47 } };
205 1.1.1.1.2.2 pgoyette int badDataSize[6] = { 1, 1, 2, 2, 2, 2 };
206 1.1.1.1.2.2 pgoyette int i;
207 1.1.1.1.2.2 pgoyette
208 1.1.1.1.2.2 pgoyette mpfr_init2 (x, 2);
209 1.1.1.1.2.2 pgoyette status = mpfr_fpif_export (NULL, x);
210 1.1.1.1.2.2 pgoyette if (status == 0)
211 1.1.1.1.2.2 pgoyette {
212 1.1.1.1.2.2 pgoyette printf ("mpfr_fpif_export did not fail with a NULL file\n");
213 1.1.1.1.2.2 pgoyette exit(1);
214 1.1.1.1.2.2 pgoyette }
215 1.1.1.1.2.2 pgoyette status = mpfr_fpif_import (x, NULL);
216 1.1.1.1.2.2 pgoyette if (status == 0)
217 1.1.1.1.2.2 pgoyette {
218 1.1.1.1.2.2 pgoyette printf ("mpfr_fpif_import did not fail with a NULL file\n");
219 1.1.1.1.2.2 pgoyette exit(1);
220 1.1.1.1.2.2 pgoyette }
221 1.1.1.1.2.2 pgoyette
222 1.1.1.1.2.2 pgoyette fh = fopen (filenameCompressed, "w+");
223 1.1.1.1.2.2 pgoyette if (fh == NULL)
224 1.1.1.1.2.2 pgoyette {
225 1.1.1.1.2.2 pgoyette printf ("Failed to open for reading/writing %s, exiting...\n",
226 1.1.1.1.2.2 pgoyette filenameCompressed);
227 1.1.1.1.2.2 pgoyette fclose (fh);
228 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
229 1.1.1.1.2.2 pgoyette exit (1);
230 1.1.1.1.2.2 pgoyette }
231 1.1.1.1.2.2 pgoyette status = mpfr_fpif_import (x, fh);
232 1.1.1.1.2.2 pgoyette if (status == 0)
233 1.1.1.1.2.2 pgoyette {
234 1.1.1.1.2.2 pgoyette printf ("mpfr_fpif_import did not fail on a empty file\n");
235 1.1.1.1.2.2 pgoyette fclose (fh);
236 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
237 1.1.1.1.2.2 pgoyette exit(1);
238 1.1.1.1.2.2 pgoyette }
239 1.1.1.1.2.2 pgoyette
240 1.1.1.1.2.2 pgoyette for (i = 0; i < 6; i++)
241 1.1.1.1.2.2 pgoyette {
242 1.1.1.1.2.2 pgoyette rewind (fh);
243 1.1.1.1.2.2 pgoyette status = fwrite (&badData[i][0], badDataSize[i], 1, fh);
244 1.1.1.1.2.2 pgoyette if (status != 1)
245 1.1.1.1.2.2 pgoyette {
246 1.1.1.1.2.2 pgoyette printf ("Write error on the test file\n");
247 1.1.1.1.2.2 pgoyette fclose (fh);
248 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
249 1.1.1.1.2.2 pgoyette exit(1);
250 1.1.1.1.2.2 pgoyette }
251 1.1.1.1.2.2 pgoyette rewind (fh);
252 1.1.1.1.2.2 pgoyette status = mpfr_fpif_import (x, fh);
253 1.1.1.1.2.2 pgoyette if (status == 0)
254 1.1.1.1.2.2 pgoyette {
255 1.1.1.1.2.2 pgoyette printf ("mpfr_fpif_import did not fail on a bad imported data\n");
256 1.1.1.1.2.2 pgoyette switch (i)
257 1.1.1.1.2.2 pgoyette {
258 1.1.1.1.2.2 pgoyette case 0:
259 1.1.1.1.2.2 pgoyette printf (" not enough precision data\n");
260 1.1.1.1.2.2 pgoyette break;
261 1.1.1.1.2.2 pgoyette case 1:
262 1.1.1.1.2.2 pgoyette printf (" no exponent data\n");
263 1.1.1.1.2.2 pgoyette break;
264 1.1.1.1.2.2 pgoyette case 2:
265 1.1.1.1.2.2 pgoyette printf (" too big exponent\n");
266 1.1.1.1.2.2 pgoyette break;
267 1.1.1.1.2.2 pgoyette case 3:
268 1.1.1.1.2.2 pgoyette printf (" not enough exponent data\n");
269 1.1.1.1.2.2 pgoyette break;
270 1.1.1.1.2.2 pgoyette case 4:
271 1.1.1.1.2.2 pgoyette printf (" exponent data wrong\n");
272 1.1.1.1.2.2 pgoyette break;
273 1.1.1.1.2.2 pgoyette case 5:
274 1.1.1.1.2.2 pgoyette printf (" no limb data\n");
275 1.1.1.1.2.2 pgoyette break;
276 1.1.1.1.2.2 pgoyette default:
277 1.1.1.1.2.2 pgoyette printf ("Test fatal error, unknown case\n");
278 1.1.1.1.2.2 pgoyette break;
279 1.1.1.1.2.2 pgoyette }
280 1.1.1.1.2.2 pgoyette fclose (fh);
281 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
282 1.1.1.1.2.2 pgoyette exit(1);
283 1.1.1.1.2.2 pgoyette }
284 1.1.1.1.2.2 pgoyette }
285 1.1.1.1.2.2 pgoyette
286 1.1.1.1.2.2 pgoyette fclose (fh);
287 1.1.1.1.2.2 pgoyette mpfr_clear (x);
288 1.1.1.1.2.2 pgoyette
289 1.1.1.1.2.2 pgoyette fh = fopen (filenameCompressed, "r");
290 1.1.1.1.2.2 pgoyette if (fh == NULL)
291 1.1.1.1.2.2 pgoyette {
292 1.1.1.1.2.2 pgoyette printf ("Failed to open for reading %s, exiting...\n",
293 1.1.1.1.2.2 pgoyette filenameCompressed);
294 1.1.1.1.2.2 pgoyette exit (1);
295 1.1.1.1.2.2 pgoyette }
296 1.1.1.1.2.2 pgoyette
297 1.1.1.1.2.2 pgoyette mpfr_init2 (x, 2);
298 1.1.1.1.2.2 pgoyette status = mpfr_fpif_export (fh, x);
299 1.1.1.1.2.2 pgoyette if (status == 0)
300 1.1.1.1.2.2 pgoyette {
301 1.1.1.1.2.2 pgoyette printf ("mpfr_fpif_export did not fail on a read only stream\n");
302 1.1.1.1.2.2 pgoyette exit(1);
303 1.1.1.1.2.2 pgoyette }
304 1.1.1.1.2.2 pgoyette fclose (fh);
305 1.1.1.1.2.2 pgoyette remove (filenameCompressed);
306 1.1.1.1.2.2 pgoyette mpfr_clear (x);
307 1.1.1.1.2.2 pgoyette }
308 1.1.1.1.2.2 pgoyette
309 1.1.1.1.2.2 pgoyette /* exercise error when precision > MPFR_PREC_MAX */
310 1.1.1.1.2.2 pgoyette static void
311 1.1.1.1.2.2 pgoyette extra (void)
312 1.1.1.1.2.2 pgoyette {
313 1.1.1.1.2.2 pgoyette char *data = FILE_NAME_R2;
314 1.1.1.1.2.2 pgoyette mpfr_t x;
315 1.1.1.1.2.2 pgoyette FILE *fp;
316 1.1.1.1.2.2 pgoyette int ret;
317 1.1.1.1.2.2 pgoyette
318 1.1.1.1.2.2 pgoyette mpfr_init2 (x, 17);
319 1.1.1.1.2.2 pgoyette mpfr_set_ui (x, 42, MPFR_RNDN);
320 1.1.1.1.2.2 pgoyette fp = src_fopen (data, "r");
321 1.1.1.1.2.2 pgoyette if (fp == NULL)
322 1.1.1.1.2.2 pgoyette {
323 1.1.1.1.2.2 pgoyette printf ("Failed to open for reading %s in srcdir, exiting...\n", data);
324 1.1.1.1.2.2 pgoyette exit (1);
325 1.1.1.1.2.2 pgoyette }
326 1.1.1.1.2.2 pgoyette ret = mpfr_fpif_import (x, fp);
327 1.1.1.1.2.2 pgoyette MPFR_ASSERTN (ret != 0); /* import failure */
328 1.1.1.1.2.2 pgoyette MPFR_ASSERTN (mpfr_get_prec (x) == 17); /* precision did not change */
329 1.1.1.1.2.2 pgoyette MPFR_ASSERTN (mpfr_cmp_ui0 (x, 42) == 0); /* value is still 42 */
330 1.1.1.1.2.2 pgoyette fclose (fp);
331 1.1.1.1.2.2 pgoyette mpfr_clear (x);
332 1.1.1.1.2.2 pgoyette }
333 1.1.1.1.2.2 pgoyette
334 1.1.1.1.2.2 pgoyette int
335 1.1.1.1.2.2 pgoyette main (int argc, char *argv[])
336 1.1.1.1.2.2 pgoyette {
337 1.1.1.1.2.2 pgoyette if (argc != 1)
338 1.1.1.1.2.2 pgoyette {
339 1.1.1.1.2.2 pgoyette printf ("Usage: %s\n", argv[0]);
340 1.1.1.1.2.2 pgoyette exit (1);
341 1.1.1.1.2.2 pgoyette }
342 1.1.1.1.2.2 pgoyette
343 1.1.1.1.2.2 pgoyette tests_start_mpfr ();
344 1.1.1.1.2.2 pgoyette
345 1.1.1.1.2.2 pgoyette extra ();
346 1.1.1.1.2.2 pgoyette doit (argc, argv, 130, 2048);
347 1.1.1.1.2.2 pgoyette doit (argc, argv, 1, 53);
348 1.1.1.1.2.2 pgoyette check_bad ();
349 1.1.1.1.2.2 pgoyette
350 1.1.1.1.2.2 pgoyette tests_end_mpfr ();
351 1.1.1.1.2.2 pgoyette
352 1.1.1.1.2.2 pgoyette return 0;
353 1.1.1.1.2.2 pgoyette }
354