@@ -433,28 +433,28 @@ bool check_file(std::string file_name) {
433
433
if (str.size () > 0 ) {
434
434
#ifdef __STDCPP_FLOAT16_T__
435
435
// Read 16-bit hex
436
- uint16_t float16;
436
+ uint16_t float16{} ;
437
437
auto r16 =
438
438
std::from_chars (str.data (), str.data () + str.size (), float16, 16 );
439
439
if (r16.ec != std::errc ()) {
440
- std::cerr << " 16-bit parsing failure\n " ;
440
+ std::cerr << " 16-bit parsing failure: " << str << " \n " ;
441
441
return false ;
442
442
}
443
443
#endif
444
444
// Read 32-bit hex
445
- uint32_t float32;
445
+ uint32_t float32{} ;
446
446
auto r32 = std::from_chars (str.data () + 5 , str.data () + str.size (),
447
447
float32, 16 );
448
448
if (r32.ec != std::errc ()) {
449
- std::cerr << " 32-bit parsing failure\n " ;
449
+ std::cerr << " 32-bit parsing failure: " << str << " \n " ;
450
450
return false ;
451
451
}
452
452
// Read 64-bit hex
453
- uint64_t float64;
453
+ uint64_t float64{} ;
454
454
auto r64 = std::from_chars (str.data () + 14 , str.data () + str.size (),
455
455
float64, 16 );
456
456
if (r64.ec != std::errc ()) {
457
- std::cerr << " 64-bit parsing failure\n " ;
457
+ std::cerr << " 64-bit parsing failure: " << str << " \n " ;
458
458
return false ;
459
459
}
460
460
// The string to parse:
@@ -467,34 +467,34 @@ bool check_file(std::string file_name) {
467
467
fast_float::from_chars (number_string, end_of_string, parsed_16);
468
468
if (fast_float_r16.ec != std::errc () &&
469
469
fast_float_r16.ec != std::errc::result_out_of_range) {
470
- std::cerr << " 16-bit fast_float parsing failure for : " + str + " \n " ;
470
+ std::cerr << " 16-bit fast_float parsing failure: " << str << " \n " ;
471
471
return false ;
472
472
}
473
473
#endif
474
474
// Parse as 32-bit float
475
- float parsed_32;
475
+ float parsed_32{} ;
476
476
auto fast_float_r32 =
477
477
fast_float::from_chars (number_string, end_of_string, parsed_32);
478
478
if (fast_float_r32.ec != std::errc () &&
479
479
fast_float_r32.ec != std::errc::result_out_of_range) {
480
- std::cerr << " 32-bit fast_float parsing failure for : " + str + " \n " ;
480
+ std::cerr << " 32-bit fast_float parsing failure: " << str << " \n " ;
481
481
return false ;
482
482
}
483
483
// Parse as 64-bit float
484
- double parsed_64;
484
+ double parsed_64{} ;
485
485
auto fast_float_r64 =
486
486
fast_float::from_chars (number_string, end_of_string, parsed_64);
487
487
if (fast_float_r64.ec != std::errc () &&
488
488
fast_float_r32.ec != std::errc::result_out_of_range) {
489
- std::cerr << " 64-bit fast_float parsing failure: " + str + " \n " ;
489
+ std::cerr << " 64-bit fast_float parsing failure: " << str << " \n " ;
490
490
return false ;
491
491
}
492
492
// Convert the floats to unsigned ints.
493
493
#ifdef __STDCPP_FLOAT16_T__
494
- uint16_t float16_parsed;
494
+ uint16_t float16_parsed{} ;
495
495
#endif
496
- uint32_t float32_parsed;
497
- uint64_t float64_parsed;
496
+ uint32_t float32_parsed{} ;
497
+ uint64_t float64_parsed{} ;
498
498
#ifdef __STDCPP_FLOAT16_T__
499
499
::memcpy (&float16_parsed, &parsed_16, sizeof (parsed_16));
500
500
@@ -504,27 +504,27 @@ bool check_file(std::string file_name) {
504
504
// Compare with expected results
505
505
#ifdef __STDCPP_FLOAT16_T__
506
506
if (float16_parsed != float16) {
507
- std::cout << " bad 16 " << str << std::endl;
508
- std::cout << " parsed as " << iHexAndDec (parsed_16) << std::endl;
509
- std::cout << " as raw uint16_t, parsed = " << float16_parsed
507
+ std::cout << " bad 16: " << str << std::endl;
508
+ std::cout << " parsed as " << fHexAndDec (parsed_16) << std::endl;
509
+ std::cout << " as raw uint16_t, parsed = " << float16_parsed
510
510
<< " , expected = " << float16 << std::endl;
511
511
std::cout << " fesetround: " << round_name (d) << std::endl;
512
512
fesetround (FE_TONEAREST);
513
513
return false ;
514
514
}
515
515
#endif
516
516
if (float32_parsed != float32) {
517
- std::cout << " bad 32 " << str << std::endl;
518
- std::cout << " parsed as " << iHexAndDec (parsed_32) << std::endl;
519
- std::cout << " as raw uint32_t, parsed = " << float32_parsed
517
+ std::cout << " bad 32: " << str << std::endl;
518
+ std::cout << " parsed as " << fHexAndDec (parsed_32) << std::endl;
519
+ std::cout << " as raw uint32_t, parsed = " << float32_parsed
520
520
<< " , expected = " << float32 << std::endl;
521
521
std::cout << " fesetround: " << round_name (d) << std::endl;
522
522
fesetround (FE_TONEAREST);
523
523
return false ;
524
524
}
525
525
if (float64_parsed != float64) {
526
- std::cout << " bad 64 " << str << std::endl;
527
- std::cout << " parsed as " << iHexAndDec (parsed_64) << std::endl;
526
+ std::cout << " bad 64: " << str << std::endl;
527
+ std::cout << " parsed as " << fHexAndDec (parsed_64) << std::endl;
528
528
std::cout << " as raw uint64_t, parsed = " << float64_parsed
529
529
<< " , expected = " << float64 << std::endl;
530
530
std::cout << " fesetround: " << round_name (d) << std::endl;
@@ -550,7 +550,9 @@ bool check_file(std::string file_name) {
550
550
TEST_CASE (" supplemental" ) {
551
551
std::string path = SUPPLEMENTAL_TEST_DATA_DIR;
552
552
for (auto const &entry : std::filesystem::directory_iterator (path)) {
553
- CHECK (check_file (entry.path ().string ()));
553
+ const auto file = entry.path ().string ();
554
+ CAPTURE (file);
555
+ CHECK (check_file (file));
554
556
}
555
557
}
556
558
#endif
0 commit comments