@@ -333,6 +333,87 @@ fn test_f64() {
333
333
. stdout_is ( expected_output) ;
334
334
}
335
335
336
+ #[ test]
337
+ fn test_f128 ( ) {
338
+ // This actually tests f80 parsing (x86(-64) behavior.
339
+ // Top 48-bits are ignored, padded with semi-random values here
340
+ let input: [ u8 ; 19 * 16 ] = [
341
+ // Examples from Wikipedia: https://en.wikipedia.org/wiki/Extended_precision
342
+ // ... m ....................................] [exp+sign] [ padding (48 bits) .....
343
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff ,
344
+ 0xcf , // 3.64519953188247460252841 × 10^−4951 (smallest positive subnormal number)
345
+ 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0x7f , 0x00 , 0x00 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
346
+ 0xca , // 3.36210314311209350589816 × 10^−4932 (largest subnormal number)
347
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x01 , 0x00 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
348
+ 0xca , // 3.36210314311209350626268 × 10^−4932 (smallest positive normal number)
349
+ 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xfe , 0x7f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
350
+ 0xca , // 1.18973149535723176502126 × 10^4932 (largest normal number)
351
+ 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xfe , 0x3f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
352
+ 0xca , // 0.99999999999999999994579 (largest number less than one)
353
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0x3f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
354
+ 0xca , // 1 (one)
355
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0x3f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
356
+ 0xca , // 1.00000000000000000010842 (smallest number larger than one)
357
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x00 , 0x40 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
358
+ 0xca , // 2
359
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x00 , 0xc0 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
360
+ 0xca , // -2
361
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
362
+ 0xca , // 0
363
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
364
+ 0xca , // -0
365
+ 0x35 , 0xc2 , 0x68 , 0x21 , 0xa2 , 0xda , 0x0f , 0xc9 , 0x00 , 0x40 , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
366
+ 0xca , //3.14159265358979323851281 (closest approximation to pi)
367
+ // Others:
368
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff ,
369
+ 0xff , // 3.64519953188247460252841 × 10^−4951 (pseudo-subnormal number)
370
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0x7f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
371
+ 0xca , // pseudo-infinity => parsed as nan
372
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0x7f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
373
+ 0xca , // infinity
374
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0xff , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
375
+ 0xca , // -infinity
376
+ 0xab , 0xcd , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0x7f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
377
+ 0xca , // pseudo-nan
378
+ 0xab , 0xba , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0x7f , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
379
+ 0xca , // nan
380
+ 0xab , 0xba , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0xff , 0xff , 0xfe , 0xca , 0xfe , 0xca , 0xfe ,
381
+ 0xca , // -nan
382
+ ] ;
383
+ let expected_output = unindent (
384
+ "
385
+ 0000000 3.6451995318824746025e-4951
386
+ 0000020 3.3621031431120935059e-4932
387
+ 0000040 3.3621031431120935063e-4932
388
+ 0000060 1.189731495357231765e+4932
389
+ 0000100 0.99999999999999999995
390
+ 0000120 1
391
+ 0000140 1.0000000000000000001
392
+ 0000160 2
393
+ 0000200 -2
394
+ 0000220 0
395
+ 0000240 -0
396
+ 0000260 3.1415926535897932385
397
+ 0000300 3.6451995318824746025e-4951
398
+ 0000320 nan
399
+ 0000340 inf
400
+ 0000360 -inf
401
+ 0000400 nan
402
+ 0000420 nan
403
+ 0000440 -nan
404
+ 0000460
405
+ " ,
406
+ ) ;
407
+ new_ucmd ! ( )
408
+ . arg ( "--endian=little" )
409
+ . arg ( "-tfL" )
410
+ . arg ( "-w16" )
411
+ . run_piped_stdin ( & input[ ..] )
412
+ . success ( )
413
+ . no_stderr ( )
414
+ . stdout_is ( expected_output) ;
415
+ }
416
+
336
417
#[ test]
337
418
fn test_multibyte ( ) {
338
419
let input = "’‐ˆ‘˜語🙂✅🐶𝛑Universität Tübingen \u{1B000} " ; // spell-checker:disable-line
0 commit comments