1 // Basic sanity tests of I/O API; exhaustive testing will be done in Fortran
2
3 #include "testing.h"
4 #include "../../runtime/descriptor.h"
5 #include "../../runtime/io-api.h"
6 #include <cstring>
7
8 using namespace Fortran::runtime;
9 using namespace Fortran::runtime::io;
10
test(const char * format,const char * expect,std::string && got)11 static bool test(const char *format, const char *expect, std::string &&got) {
12 std::string want{expect};
13 want.resize(got.length(), ' ');
14 if (got != want) {
15 Fail() << '\'' << format << "' failed;\n got '" << got
16 << "',\nexpected '" << want << "'\n";
17 return false;
18 }
19 return true;
20 }
21
hello()22 static void hello() {
23 char buffer[32];
24 const char *format{"(6HHELLO,,A6,2X,I3,1X,'0x',Z8,1X,L1)"};
25 auto cookie{IONAME(BeginInternalFormattedOutput)(
26 buffer, sizeof buffer, format, std::strlen(format))};
27 IONAME(OutputAscii)(cookie, "WORLD", 5);
28 IONAME(OutputInteger64)(cookie, 678);
29 IONAME(OutputInteger64)(cookie, 0xfeedface);
30 IONAME(OutputLogical)(cookie, true);
31 if (auto status{IONAME(EndIoStatement)(cookie)}) {
32 Fail() << "hello: '" << format << "' failed, status "
33 << static_cast<int>(status) << '\n';
34 } else {
35 test(format, "HELLO, WORLD 678 0xFEEDFACE T",
36 std::string{buffer, sizeof buffer});
37 }
38 }
39
multiline()40 static void multiline() {
41 char buffer[5][32];
42 StaticDescriptor<1> staticDescriptor[2];
43 Descriptor &whole{staticDescriptor[0].descriptor()};
44 SubscriptValue extent[]{5};
45 whole.Establish(TypeCode{CFI_type_char}, sizeof buffer[0], &buffer, 1, extent,
46 CFI_attribute_pointer);
47 whole.Dump();
48 whole.Check();
49 Descriptor §ion{staticDescriptor[1].descriptor()};
50 SubscriptValue lowers[]{0}, uppers[]{4}, strides[]{1};
51 section.Establish(whole.type(), whole.ElementBytes(), nullptr, 1, extent,
52 CFI_attribute_pointer);
53 if (auto error{
54 CFI_section(§ion.raw(), &whole.raw(), lowers, uppers, strides)}) {
55 Fail() << "multiline: CFI_section failed: " << error << '\n';
56 return;
57 }
58 section.Dump();
59 section.Check();
60 const char *format{
61 "('?abcde,',T1,'>',T9,A,TL12,A,TR25,'<'//G0,17X,'abcd',1(2I4))"};
62 auto cookie{IONAME(BeginInternalArrayFormattedOutput)(
63 section, format, std::strlen(format))};
64 IONAME(OutputAscii)(cookie, "WORLD", 5);
65 IONAME(OutputAscii)(cookie, "HELLO", 5);
66 IONAME(OutputInteger64)(cookie, 789);
67 for (int j{666}; j <= 999; j += 111) {
68 IONAME(OutputInteger64)(cookie, j);
69 }
70 if (auto status{IONAME(EndIoStatement)(cookie)}) {
71 Fail() << "multiline: '" << format << "' failed, status "
72 << static_cast<int>(status) << '\n';
73 } else {
74 test(format,
75 ">HELLO, WORLD <"
76 " "
77 "789 abcd 666 777"
78 " 888 999 "
79 " ",
80 std::string{buffer[0], sizeof buffer});
81 }
82 }
83
listInputTest()84 static void listInputTest() {
85 static const char input[]{",1*,(5.,6..)"};
86 auto cookie{IONAME(BeginInternalListInput)(input, sizeof input - 1)};
87 float z[6];
88 for (int j{0}; j < 6; ++j) {
89 z[j] = -(j + 1);
90 }
91 for (int j{0}; j < 6; j += 2) {
92 if (!IONAME(InputComplex32)(cookie, &z[j])) {
93 Fail() << "InputComplex32 failed\n";
94 }
95 }
96 auto status{IONAME(EndIoStatement)(cookie)};
97 if (status) {
98 Fail() << "Failed complex list-directed input, status "
99 << static_cast<int>(status) << '\n';
100 } else {
101 char output[33];
102 output[32] = '\0';
103 cookie = IONAME(BeginInternalListOutput)(output, 32);
104 for (int j{0}; j < 6; j += 2) {
105 if (!IONAME(OutputComplex32)(cookie, z[j], z[j + 1])) {
106 Fail() << "OutputComplex32 failed\n";
107 }
108 }
109 status = IONAME(EndIoStatement)(cookie);
110 static const char expect[33]{" (-1.,-2.) (-3.,-4.) (5.,6.) "};
111 if (status) {
112 Fail() << "Failed complex list-directed output, status "
113 << static_cast<int>(status) << '\n';
114 } else if (std::strncmp(output, expect, 33) != 0) {
115 Fail() << "Failed complex list-directed output, expected '" << expect
116 << "', but got '" << output << "'\n";
117 }
118 }
119 }
120
descrOutputTest()121 static void descrOutputTest() {
122 char buffer[9];
123 // Formatted
124 const char *format{"(2A4)"};
125 auto cookie{IONAME(BeginInternalFormattedOutput)(
126 buffer, sizeof buffer, format, std::strlen(format))};
127 StaticDescriptor<1> staticDescriptor;
128 Descriptor &desc{staticDescriptor.descriptor()};
129 SubscriptValue extent[]{2};
130 char data[2][4];
131 std::memcpy(data[0], "ABCD", 4);
132 std::memcpy(data[1], "EFGH", 4);
133 desc.Establish(TypeCode{CFI_type_char}, sizeof data[0], &data, 1, extent);
134 desc.Dump();
135 desc.Check();
136 IONAME(OutputDescriptor)(cookie, desc);
137 if (auto status{IONAME(EndIoStatement)(cookie)}) {
138 Fail() << "descrOutputTest: '" << format << "' failed, status "
139 << static_cast<int>(status) << '\n';
140 } else {
141 test("descrOutputTest(formatted)", "ABCDEFGH ",
142 std::string{buffer, sizeof buffer});
143 }
144 // List-directed
145 cookie = IONAME(BeginInternalListOutput)(buffer, sizeof buffer);
146 IONAME(OutputDescriptor)(cookie, desc);
147 if (auto status{IONAME(EndIoStatement)(cookie)}) {
148 Fail() << "descrOutputTest: list-directed failed, status "
149 << static_cast<int>(status) << '\n';
150 } else {
151 test("descrOutputTest(list)", " ABCDEFGH",
152 std::string{buffer, sizeof buffer});
153 }
154 }
155
realTest(const char * format,double x,const char * expect)156 static void realTest(const char *format, double x, const char *expect) {
157 char buffer[800];
158 auto cookie{IONAME(BeginInternalFormattedOutput)(
159 buffer, sizeof buffer, format, std::strlen(format))};
160 IONAME(OutputReal64)(cookie, x);
161 if (auto status{IONAME(EndIoStatement)(cookie)}) {
162 Fail() << '\'' << format << "' failed, status " << static_cast<int>(status)
163 << '\n';
164 } else {
165 test(format, expect, std::string{buffer, sizeof buffer});
166 }
167 }
168
realInTest(const char * format,const char * data,std::uint64_t want)169 static void realInTest(
170 const char *format, const char *data, std::uint64_t want) {
171 auto cookie{IONAME(BeginInternalFormattedInput)(
172 data, std::strlen(data), format, std::strlen(format))};
173 union {
174 double x;
175 std::uint64_t raw;
176 } u;
177 u.raw = 0;
178 IONAME(EnableHandlers)(cookie, true, true, true, true, true);
179 IONAME(InputReal64)(cookie, u.x);
180 char iomsg[65];
181 iomsg[0] = '\0';
182 iomsg[sizeof iomsg - 1] = '\0';
183 IONAME(GetIoMsg)(cookie, iomsg, sizeof iomsg - 1);
184 auto status{IONAME(EndIoStatement)(cookie)};
185 if (status) {
186 Fail() << '\'' << format << "' failed reading '" << data << "', status "
187 << static_cast<int>(status) << " iomsg '" << iomsg << "'\n";
188 } else if (u.raw != want) {
189 Fail() << '\'' << format << "' failed reading '" << data << "', want 0x";
190 Fail().write_hex(want) << ", got 0x" << u.raw << '\n';
191 }
192 }
193
main()194 int main() {
195 StartTests();
196
197 hello();
198 multiline();
199
200 static const char *zeroes[][2]{
201 {"(E32.17,';')", " 0.00000000000000000E+00;"},
202 {"(F32.17,';')", " 0.00000000000000000;"},
203 {"(G32.17,';')", " 0.0000000000000000 ;"},
204 {"(DC,E32.17,';')", " 0,00000000000000000E+00;"},
205 {"(DC,F32.17,';')", " 0,00000000000000000;"},
206 {"(DC,G32.17,';')", " 0,0000000000000000 ;"},
207 {"(D32.17,';')", " 0.00000000000000000D+00;"},
208 {"(E32.17E1,';')", " 0.00000000000000000E+0;"},
209 {"(G32.17E1,';')", " 0.0000000000000000 ;"},
210 {"(E32.17E0,';')", " 0.00000000000000000E+0;"},
211 {"(G32.17E0,';')", " 0.0000000000000000 ;"},
212 {"(1P,E32.17,';')", " 0.00000000000000000E+00;"},
213 {"(1PE32.17,';')", " 0.00000000000000000E+00;"}, // no comma
214 {"(1P,F32.17,';')", " 0.00000000000000000;"},
215 {"(1P,G32.17,';')", " 0.0000000000000000 ;"},
216 {"(2P,E32.17,';')", " 00.0000000000000000E+00;"},
217 {"(-1P,E32.17,';')", " 0.00000000000000000E+00;"},
218 {"(G0,';')", "0.;"}, {}};
219 for (int j{0}; zeroes[j][0]; ++j) {
220 realTest(zeroes[j][0], 0.0, zeroes[j][1]);
221 }
222
223 static const char *ones[][2]{
224 {"(E32.17,';')", " 0.10000000000000000E+01;"},
225 {"(F32.17,';')", " 1.00000000000000000;"},
226 {"(G32.17,';')", " 1.0000000000000000 ;"},
227 {"(E32.17E1,';')", " 0.10000000000000000E+1;"},
228 {"(G32.17E1,';')", " 1.0000000000000000 ;"},
229 {"(E32.17E0,';')", " 0.10000000000000000E+1;"},
230 {"(G32.17E0,';')", " 1.0000000000000000 ;"},
231 {"(E32.17E4,';')", " 0.10000000000000000E+0001;"},
232 {"(G32.17E4,';')", " 1.0000000000000000 ;"},
233 {"(1P,E32.17,';')", " 1.00000000000000000E+00;"},
234 {"(1PE32.17,';')", " 1.00000000000000000E+00;"}, // no comma
235 {"(1P,F32.17,';')", " 10.00000000000000000;"},
236 {"(1P,G32.17,';')", " 1.0000000000000000 ;"},
237 {"(ES32.17,';')", " 1.00000000000000000E+00;"},
238 {"(2P,E32.17,';')", " 10.0000000000000000E-01;"},
239 {"(2P,G32.17,';')", " 1.0000000000000000 ;"},
240 {"(-1P,E32.17,';')", " 0.01000000000000000E+02;"},
241 {"(-1P,G32.17,';')", " 1.0000000000000000 ;"},
242 {"(G0,';')", "1.;"}, {}};
243 for (int j{0}; ones[j][0]; ++j) {
244 realTest(ones[j][0], 1.0, ones[j][1]);
245 }
246
247 realTest("(E32.17,';')", -1.0, " -0.10000000000000000E+01;");
248 realTest("(F32.17,';')", -1.0, " -1.00000000000000000;");
249 realTest("(G32.17,';')", -1.0, " -1.0000000000000000 ;");
250 realTest("(G0,';')", -1.0, "-1.;");
251
252 volatile union {
253 double d;
254 std::uint64_t n;
255 } u;
256 u.n = 0x8000000000000000; // -0
257 realTest("(E9.1,';')", u.d, " -0.0E+00;");
258 realTest("(F4.0,';')", u.d, " -0.;");
259 realTest("(G8.0,';')", u.d, "-0.0E+00;");
260 realTest("(G8.1,';')", u.d, " -0. ;");
261 realTest("(G0,';')", u.d, "-0.;");
262 u.n = 0x7ff0000000000000; // +Inf
263 realTest("(E9.1,';')", u.d, " Inf;");
264 realTest("(F9.1,';')", u.d, " Inf;");
265 realTest("(G9.1,';')", u.d, " Inf;");
266 realTest("(SP,E9.1,';')", u.d, " +Inf;");
267 realTest("(SP,F9.1,';')", u.d, " +Inf;");
268 realTest("(SP,G9.1,';')", u.d, " +Inf;");
269 realTest("(G0,';')", u.d, "Inf;");
270 u.n = 0xfff0000000000000; // -Inf
271 realTest("(E9.1,';')", u.d, " -Inf;");
272 realTest("(F9.1,';')", u.d, " -Inf;");
273 realTest("(G9.1,';')", u.d, " -Inf;");
274 realTest("(G0,';')", u.d, "-Inf;");
275 u.n = 0x7ff0000000000001; // NaN
276 realTest("(E9.1,';')", u.d, " NaN;");
277 realTest("(F9.1,';')", u.d, " NaN;");
278 realTest("(G9.1,';')", u.d, " NaN;");
279 realTest("(G0,';')", u.d, "NaN;");
280 u.n = 0xfff0000000000001; // NaN (sign irrelevant)
281 realTest("(E9.1,';')", u.d, " NaN;");
282 realTest("(F9.1,';')", u.d, " NaN;");
283 realTest("(G9.1,';')", u.d, " NaN;");
284 realTest("(SP,E9.1,';')", u.d, " NaN;");
285 realTest("(SP,F9.1,';')", u.d, " NaN;");
286 realTest("(SP,G9.1,';')", u.d, " NaN;");
287 realTest("(G0,';')", u.d, "NaN;");
288
289 u.n = 0x3fb999999999999a; // 0.1 rounded
290 realTest("(E62.55,';')", u.d,
291 " 0.1000000000000000055511151231257827021181583404541015625E+00;");
292 realTest("(E0.0,';')", u.d, "0.E+00;");
293 realTest("(E0.55,';')", u.d,
294 "0.1000000000000000055511151231257827021181583404541015625E+00;");
295 realTest("(E0,';')", u.d, ".1E+00;");
296 realTest("(F58.55,';')", u.d,
297 " 0.1000000000000000055511151231257827021181583404541015625;");
298 realTest("(F0.0,';')", u.d, "0.;");
299 realTest("(F0.55,';')", u.d,
300 ".1000000000000000055511151231257827021181583404541015625;");
301 realTest("(F0,';')", u.d, ".1;");
302 realTest("(G62.55,';')", u.d,
303 " 0.1000000000000000055511151231257827021181583404541015625 ;");
304 realTest("(G0.0,';')", u.d, "0.;");
305 realTest("(G0.55,';')", u.d,
306 ".1000000000000000055511151231257827021181583404541015625;");
307 realTest("(G0,';')", u.d, ".1;");
308
309 u.n = 0x3ff8000000000000; // 1.5
310 realTest("(E9.2,';')", u.d, " 0.15E+01;");
311 realTest("(F4.1,';')", u.d, " 1.5;");
312 realTest("(G7.1,';')", u.d, " 2. ;");
313 realTest("(RN,E8.1,';')", u.d, " 0.2E+01;");
314 realTest("(RN,F3.0,';')", u.d, " 2.;");
315 realTest("(RN,G7.0,';')", u.d, " 0.E+01;");
316 realTest("(RN,G7.1,';')", u.d, " 2. ;");
317 realTest("(RD,E8.1,';')", u.d, " 0.1E+01;");
318 realTest("(RD,F3.0,';')", u.d, " 1.;");
319 realTest("(RD,G7.0,';')", u.d, " 0.E+01;");
320 realTest("(RD,G7.1,';')", u.d, " 1. ;");
321 realTest("(RU,E8.1,';')", u.d, " 0.2E+01;");
322 realTest("(RU,G7.0,';')", u.d, " 0.E+01;");
323 realTest("(RU,G7.1,';')", u.d, " 2. ;");
324 realTest("(RZ,E8.1,';')", u.d, " 0.1E+01;");
325 realTest("(RZ,F3.0,';')", u.d, " 1.;");
326 realTest("(RZ,G7.0,';')", u.d, " 0.E+01;");
327 realTest("(RZ,G7.1,';')", u.d, " 1. ;");
328 realTest("(RC,E8.1,';')", u.d, " 0.2E+01;");
329 realTest("(RC,F3.0,';')", u.d, " 2.;");
330 realTest("(RC,G7.0,';')", u.d, " 0.E+01;");
331 realTest("(RC,G7.1,';')", u.d, " 2. ;");
332
333 // TODO continue F and G editing tests on these data
334
335 u.n = 0xbff8000000000000; // -1.5
336 realTest("(E9.2,';')", u.d, "-0.15E+01;");
337 realTest("(RN,E8.1,';')", u.d, "-0.2E+01;");
338 realTest("(RD,E8.1,';')", u.d, "-0.2E+01;");
339 realTest("(RU,E8.1,';')", u.d, "-0.1E+01;");
340 realTest("(RZ,E8.1,';')", u.d, "-0.1E+01;");
341 realTest("(RC,E8.1,';')", u.d, "-0.2E+01;");
342
343 u.n = 0x4004000000000000; // 2.5
344 realTest("(E9.2,';')", u.d, " 0.25E+01;");
345 realTest("(RN,E8.1,';')", u.d, " 0.2E+01;");
346 realTest("(RD,E8.1,';')", u.d, " 0.2E+01;");
347 realTest("(RU,E8.1,';')", u.d, " 0.3E+01;");
348 realTest("(RZ,E8.1,';')", u.d, " 0.2E+01;");
349 realTest("(RC,E8.1,';')", u.d, " 0.3E+01;");
350
351 u.n = 0xc004000000000000; // -2.5
352 realTest("(E9.2,';')", u.d, "-0.25E+01;");
353 realTest("(RN,E8.1,';')", u.d, "-0.2E+01;");
354 realTest("(RD,E8.1,';')", u.d, "-0.3E+01;");
355 realTest("(RU,E8.1,';')", u.d, "-0.2E+01;");
356 realTest("(RZ,E8.1,';')", u.d, "-0.2E+01;");
357 realTest("(RC,E8.1,';')", u.d, "-0.3E+01;");
358
359 u.n = 1; // least positive nonzero subnormal
360 realTest("(E32.17,';')", u.d, " 0.49406564584124654-323;");
361 realTest("(ES32.17,';')", u.d, " 4.94065645841246544-324;");
362 realTest("(EN32.17,';')", u.d, " 4.94065645841246544-324;");
363 realTest("(E759.752,';')", u.d,
364 " 0."
365 "494065645841246544176568792868221372365059802614324764425585682500675507"
366 "270208751865299836361635992379796564695445717730926656710355939796398774"
367 "796010781878126300713190311404527845817167848982103688718636056998730723"
368 "050006387409153564984387312473397273169615140031715385398074126238565591"
369 "171026658556686768187039560310624931945271591492455329305456544401127480"
370 "129709999541931989409080416563324524757147869014726780159355238611550134"
371 "803526493472019379026810710749170333222684475333572083243193609238289345"
372 "836806010601150616980975307834227731832924790498252473077637592724787465"
373 "608477820373446969953364701797267771758512566055119913150489110145103786"
374 "273816725095583738973359899366480994116420570263709027924276754456522908"
375 "75386825064197182655334472656250-323;");
376 realTest("(G0,';')", u.d, ".5-323;");
377 realTest("(E757.750,';')", u.d,
378 " 0."
379 "494065645841246544176568792868221372365059802614324764425585682500675507"
380 "270208751865299836361635992379796564695445717730926656710355939796398774"
381 "796010781878126300713190311404527845817167848982103688718636056998730723"
382 "050006387409153564984387312473397273169615140031715385398074126238565591"
383 "171026658556686768187039560310624931945271591492455329305456544401127480"
384 "129709999541931989409080416563324524757147869014726780159355238611550134"
385 "803526493472019379026810710749170333222684475333572083243193609238289345"
386 "836806010601150616980975307834227731832924790498252473077637592724787465"
387 "608477820373446969953364701797267771758512566055119913150489110145103786"
388 "273816725095583738973359899366480994116420570263709027924276754456522908"
389 "753868250641971826553344726562-323;");
390 realTest("(RN,E757.750,';')", u.d,
391 " 0."
392 "494065645841246544176568792868221372365059802614324764425585682500675507"
393 "270208751865299836361635992379796564695445717730926656710355939796398774"
394 "796010781878126300713190311404527845817167848982103688718636056998730723"
395 "050006387409153564984387312473397273169615140031715385398074126238565591"
396 "171026658556686768187039560310624931945271591492455329305456544401127480"
397 "129709999541931989409080416563324524757147869014726780159355238611550134"
398 "803526493472019379026810710749170333222684475333572083243193609238289345"
399 "836806010601150616980975307834227731832924790498252473077637592724787465"
400 "608477820373446969953364701797267771758512566055119913150489110145103786"
401 "273816725095583738973359899366480994116420570263709027924276754456522908"
402 "753868250641971826553344726562-323;");
403 realTest("(RD,E757.750,';')", u.d,
404 " 0."
405 "494065645841246544176568792868221372365059802614324764425585682500675507"
406 "270208751865299836361635992379796564695445717730926656710355939796398774"
407 "796010781878126300713190311404527845817167848982103688718636056998730723"
408 "050006387409153564984387312473397273169615140031715385398074126238565591"
409 "171026658556686768187039560310624931945271591492455329305456544401127480"
410 "129709999541931989409080416563324524757147869014726780159355238611550134"
411 "803526493472019379026810710749170333222684475333572083243193609238289345"
412 "836806010601150616980975307834227731832924790498252473077637592724787465"
413 "608477820373446969953364701797267771758512566055119913150489110145103786"
414 "273816725095583738973359899366480994116420570263709027924276754456522908"
415 "753868250641971826553344726562-323;");
416 realTest("(RU,E757.750,';')", u.d,
417 " 0."
418 "494065645841246544176568792868221372365059802614324764425585682500675507"
419 "270208751865299836361635992379796564695445717730926656710355939796398774"
420 "796010781878126300713190311404527845817167848982103688718636056998730723"
421 "050006387409153564984387312473397273169615140031715385398074126238565591"
422 "171026658556686768187039560310624931945271591492455329305456544401127480"
423 "129709999541931989409080416563324524757147869014726780159355238611550134"
424 "803526493472019379026810710749170333222684475333572083243193609238289345"
425 "836806010601150616980975307834227731832924790498252473077637592724787465"
426 "608477820373446969953364701797267771758512566055119913150489110145103786"
427 "273816725095583738973359899366480994116420570263709027924276754456522908"
428 "753868250641971826553344726563-323;");
429 realTest("(RC,E757.750,';')", u.d,
430 " 0."
431 "494065645841246544176568792868221372365059802614324764425585682500675507"
432 "270208751865299836361635992379796564695445717730926656710355939796398774"
433 "796010781878126300713190311404527845817167848982103688718636056998730723"
434 "050006387409153564984387312473397273169615140031715385398074126238565591"
435 "171026658556686768187039560310624931945271591492455329305456544401127480"
436 "129709999541931989409080416563324524757147869014726780159355238611550134"
437 "803526493472019379026810710749170333222684475333572083243193609238289345"
438 "836806010601150616980975307834227731832924790498252473077637592724787465"
439 "608477820373446969953364701797267771758512566055119913150489110145103786"
440 "273816725095583738973359899366480994116420570263709027924276754456522908"
441 "753868250641971826553344726563-323;");
442
443 u.n = 0x10000000000000; // least positive nonzero normal
444 realTest("(E723.716,';')", u.d,
445 " 0."
446 "222507385850720138309023271733240406421921598046233183055332741688720443"
447 "481391819585428315901251102056406733973103581100515243416155346010885601"
448 "238537771882113077799353200233047961014744258363607192156504694250373420"
449 "837525080665061665815894872049117996859163964850063590877011830487479978"
450 "088775374994945158045160505091539985658247081864511353793580499211598108"
451 "576605199243335211435239014879569960959128889160299264151106346631339366"
452 "347758651302937176204732563178148566435087212282863764204484681140761391"
453 "147706280168985324411002416144742161856716615054015428508471675290190316"
454 "132277889672970737312333408698898317506783884692609277397797285865965494"
455 "10913690954061364675687023986783152906809846172109246253967285156250-"
456 "307;");
457 realTest("(G0,';')", u.d, ".22250738585072014-307;");
458
459 u.n = 0x7fefffffffffffffuLL; // greatest finite
460 realTest("(E32.17,';')", u.d, " 0.17976931348623157+309;");
461 realTest("(E317.310,';')", u.d,
462 " 0."
463 "179769313486231570814527423731704356798070567525844996598917476803157260"
464 "780028538760589558632766878171540458953514382464234321326889464182768467"
465 "546703537516986049910576551282076245490090389328944075868508455133942304"
466 "583236903222948165808559332123348274797826204144723168738177180919299881"
467 "2504040261841248583680+309;");
468 realTest("(ES317.310,';')", u.d,
469 " 1."
470 "797693134862315708145274237317043567980705675258449965989174768031572607"
471 "800285387605895586327668781715404589535143824642343213268894641827684675"
472 "467035375169860499105765512820762454900903893289440758685084551339423045"
473 "832369032229481658085593321233482747978262041447231687381771809192998812"
474 "5040402618412485836800+308;");
475 realTest("(EN319.310,';')", u.d,
476 " 179."
477 "769313486231570814527423731704356798070567525844996598917476803157260780"
478 "028538760589558632766878171540458953514382464234321326889464182768467546"
479 "703537516986049910576551282076245490090389328944075868508455133942304583"
480 "236903222948165808559332123348274797826204144723168738177180919299881250"
481 "4040261841248583680000+306;");
482 realTest("(G0,';')", u.d, ".17976931348623157+309;");
483
484 realTest("(F5.3,';')", 25., "*****;");
485 realTest("(F5.3,';')", 2.5, "2.500;");
486 realTest("(F5.3,';')", 0.25, "0.250;");
487 realTest("(F5.3,';')", 0.025, "0.025;");
488 realTest("(F5.3,';')", 0.0025, "0.003;");
489 realTest("(F5.3,';')", 0.00025, "0.000;");
490 realTest("(F5.3,';')", 0.000025, "0.000;");
491 realTest("(F5.3,';')", -25., "*****;");
492 realTest("(F5.3,';')", -2.5, "*****;");
493 realTest("(F5.3,';')", -0.25, "-.250;");
494 realTest("(F5.3,';')", -0.025, "-.025;");
495 realTest("(F5.3,';')", -0.0025, "-.003;");
496 realTest("(F5.3,';')", -0.00025, "-.000;");
497 realTest("(F5.3,';')", -0.000025, "-.000;");
498
499 realInTest("(F18.0)", " 0", 0x0);
500 realInTest("(F18.0)", " ", 0x0);
501 realInTest("(F18.0)", " -0", 0x8000000000000000);
502 realInTest("(F18.0)", " 01", 0x3ff0000000000000);
503 realInTest("(F18.0)", " 1", 0x3ff0000000000000);
504 realInTest("(F18.0)", " 125.", 0x405f400000000000);
505 realInTest("(F18.0)", " 12.5", 0x4029000000000000);
506 realInTest("(F18.0)", " 1.25", 0x3ff4000000000000);
507 realInTest("(F18.0)", " 01.25", 0x3ff4000000000000);
508 realInTest("(F18.0)", " .125", 0x3fc0000000000000);
509 realInTest("(F18.0)", " 0.125", 0x3fc0000000000000);
510 realInTest("(F18.0)", " .0625", 0x3fb0000000000000);
511 realInTest("(F18.0)", " 0.0625", 0x3fb0000000000000);
512 realInTest("(F18.0)", " 125", 0x405f400000000000);
513 realInTest("(F18.1)", " 125", 0x4029000000000000);
514 realInTest("(F18.2)", " 125", 0x3ff4000000000000);
515 realInTest("(F18.3)", " 125", 0x3fc0000000000000);
516 realInTest("(-1P,F18.0)", " 125", 0x4093880000000000); // 1250
517 realInTest("(1P,F18.0)", " 125", 0x4029000000000000); // 12.5
518 realInTest("(BZ,F18.0)", " 125 ", 0x4093880000000000); // 1250
519 realInTest("(BZ,F18.0)", " 125 . e +1 ", 0x42a6bcc41e900000); // 1.25e13
520 realInTest("(DC,F18.0)", " 12,5", 0x4029000000000000);
521
522 listInputTest();
523 descrOutputTest();
524
525 return EndTests();
526 }
527