@@ -856,49 +856,66 @@ TEST(IOApiTests, FormatIntegerValues) {
856856
857857// Ensure double input values correctly map to raw uint64 values
858858TEST (IOApiTests, EditDoubleInputValues) {
859- using TestCaseTy = std::tuple<const char *, const char *, std::uint64_t >;
859+ using TestCaseTy = std::tuple<const char *, const char *, std::uint64_t , int >;
860+ int ovf{IostatRealInputOverflow};
860861 static const std::vector<TestCaseTy> testCases{
861- {" (F18.0)" , " 0" , 0x0 },
862- {" (F18.0)" , " " , 0x0 },
863- {" (F18.0)" , " -0" , 0x8000000000000000 },
864- {" (F18.0)" , " 01" , 0x3ff0000000000000 },
865- {" (F18.0)" , " 1" , 0x3ff0000000000000 },
866- {" (F18.0)" , " 125." , 0x405f400000000000 },
867- {" (F18.0)" , " 12.5" , 0x4029000000000000 },
868- {" (F18.0)" , " 1.25" , 0x3ff4000000000000 },
869- {" (F18.0)" , " 01.25" , 0x3ff4000000000000 },
870- {" (F18.0)" , " .125" , 0x3fc0000000000000 },
871- {" (F18.0)" , " 0.125" , 0x3fc0000000000000 },
872- {" (F18.0)" , " .0625" , 0x3fb0000000000000 },
873- {" (F18.0)" , " 0.0625" , 0x3fb0000000000000 },
874- {" (F18.0)" , " 125" , 0x405f400000000000 },
875- {" (F18.1)" , " 125" , 0x4029000000000000 },
876- {" (F18.2)" , " 125" , 0x3ff4000000000000 },
877- {" (F18.3)" , " 125" , 0x3fc0000000000000 },
878- {" (-1P,F18.0)" , " 125" , 0x4093880000000000 }, // 1250
879- {" (1P,F18.0)" , " 125" , 0x4029000000000000 }, // 12.5
880- {" (BZ,F18.0)" , " 125 " , 0x4093880000000000 }, // 1250
881- {" (BZ,F18.0)" , " 125 . e +1 " , 0x42a6bcc41e900000 }, // 1.25e13
882- {" (BZ,F18.0)" , " . " , 0x0 },
883- {" (BZ,F18.0)" , " . e +1 " , 0x0 },
884- {" (DC,F18.0)" , " 12,5" , 0x4029000000000000 },
885- {" (EX22.0)" , " 0X0P0 " , 0x0 }, // +0.
886- {" (EX22.0)" , " -0X0P0 " , 0x8000000000000000 }, // -0.
887- {" (EX22.0)" , " 0X.8P1 " , 0x3ff0000000000000 }, // 1.0
888- {" (EX22.0)" , " 0X8.P-3 " , 0x3ff0000000000000 }, // 1.0
889- {" (EX22.0)" , " 0X.1P4 " , 0x3ff0000000000000 }, // 1.0
890- {" (EX22.0)" , " 0X10.P-4 " , 0x3ff0000000000000 }, // 1.0
891- {" (EX22.0)" , " 0X8.00P-3 " , 0x3ff0000000000000 }, // 1.0
892- {" (EX22.0)" , " 0X80.0P-6 " , 0x4000000000000000 }, // 2.0
893- {" (EX22.0)" , " 0XC.CCCCCCCCCCCDP-7 " , 0x3fb999999999999a }, // 0.1
894- {" (EX22.0)" , " 0X.8P-1021 " , 0x0010000000000000 }, // min normal
895- {" (EX22.0)" , " 0X.8P-1022 " , 0x0008000000000000 }, // subnormal
896- {" (EX22.0)" , " 0X.8P-1073 " , 0x0000000000000001 }, // min subn.
897- {" (EX22.0)" , " 0X.FFFFFFFFFFFFF8P1024" , 0x7fefffffffffffff }, // max finite
898- {" (EX22.0)" , " 0X.8P1025 " , 0x7ff0000000000000 }, // +Inf
899- {" (EX22.0)" , " -0X.8P1025 " , 0xfff0000000000000 }, // -Inf
862+ {" (F18.0)" , " 0" , 0x0 , 0 },
863+ {" (F18.0)" , " " , 0x0 , 0 },
864+ {" (F18.0)" , " -0" , 0x8000000000000000 , 0 },
865+ {" (F18.0)" , " 01" , 0x3ff0000000000000 , 0 },
866+ {" (F18.0)" , " 1" , 0x3ff0000000000000 , 0 },
867+ {" (F18.0)" , " 125." , 0x405f400000000000 , 0 },
868+ {" (F18.0)" , " 12.5" , 0x4029000000000000 , 0 },
869+ {" (F18.0)" , " 1.25" , 0x3ff4000000000000 , 0 },
870+ {" (F18.0)" , " 01.25" , 0x3ff4000000000000 , 0 },
871+ {" (F18.0)" , " .125" , 0x3fc0000000000000 , 0 },
872+ {" (F18.0)" , " 0.125" , 0x3fc0000000000000 , 0 },
873+ {" (F18.0)" , " .0625" , 0x3fb0000000000000 , 0 },
874+ {" (F18.0)" , " 0.0625" , 0x3fb0000000000000 , 0 },
875+ {" (F18.0)" , " 125" , 0x405f400000000000 , 0 },
876+ {" (F18.1)" , " 125" , 0x4029000000000000 , 0 },
877+ {" (F18.2)" , " 125" , 0x3ff4000000000000 , 0 },
878+ {" (F18.3)" , " 125" , 0x3fc0000000000000 , 0 },
879+ {" (-1P,F18.0)" , " 125" , 0x4093880000000000 , 0 }, // 1250
880+ {" (1P,F18.0)" , " 125" , 0x4029000000000000 , 0 }, // 12.5
881+ {" (BZ,F18.0)" , " 125 " , 0x4093880000000000 , 0 }, // 1250
882+ {" (BZ,F18.0)" , " 125 . e +1 " , 0x42a6bcc41e900000 , 0 }, // 1.25e13
883+ {" (BZ,F18.0)" , " . " , 0x0 , 0 },
884+ {" (BZ,F18.0)" , " . e +1 " , 0x0 , 0 },
885+ {" (DC,F18.0)" , " 12,5" , 0x4029000000000000 , 0 },
886+ {" (EX22.0)" , " 0X0P0 " , 0x0 , 0 }, // +0.
887+ {" (EX22.0)" , " -0X0P0 " , 0x8000000000000000 , 0 }, // -0.
888+ {" (EX22.0)" , " 0X.8P1 " , 0x3ff0000000000000 , 0 }, // 1.0
889+ {" (EX22.0)" , " 0X8.P-3 " , 0x3ff0000000000000 , 0 }, // 1.0
890+ {" (EX22.0)" , " 0X.1P4 " , 0x3ff0000000000000 , 0 }, // 1.0
891+ {" (EX22.0)" , " 0X10.P-4 " , 0x3ff0000000000000 , 0 }, // 1.0
892+ {" (EX22.0)" , " 0X8.00P-3 " , 0x3ff0000000000000 , 0 }, // 1.0
893+ {" (EX22.0)" , " 0X80.0P-6 " , 0x4000000000000000 , 0 }, // 2.0
894+ {" (EX22.0)" , " 0XC.CCCCCCCCCCCDP-7 " , 0x3fb999999999999a , 0 }, // 0.1
895+ {" (EX22.0)" , " 0X.8P-1021 " , 0x0010000000000000 ,
896+ 0 }, // min normal
897+ {" (EX22.0)" , " 0X.8P-1022 " , 0x0008000000000000 ,
898+ 0 }, // subnormal
899+ {" (EX22.0)" , " 0X.8P-1073 " , 0x0000000000000001 ,
900+ 0 }, // min subn.
901+ {" (EX22.0)" , " 0X.FFFFFFFFFFFFF8P1024" , 0x7fefffffffffffff ,
902+ 0 }, // max finite
903+ {" (EX22.0)" , " 0X.8P1025 " , 0x7ff0000000000000 , ovf}, // +Inf
904+ {" (EX22.0)" , " -0X.8P1025 " , 0xfff0000000000000 , ovf}, // -Inf
905+ {" (RZ,F7.0)" , " 2.e308" , 0x7fefffffffffffff , 0 }, // +HUGE()
906+ {" (RD,F7.0)" , " 2.e308" , 0x7fefffffffffffff , 0 }, // +HUGE()
907+ {" (RU,F7.0)" , " 2.e308" , 0x7ff0000000000000 , ovf}, // +Inf
908+ {" (RZ,F7.0)" , " -2.e308" , 0xffefffffffffffff , 0 }, // -HUGE()
909+ {" (RD,F7.0)" , " -2.e308" , 0xfff0000000000000 , ovf}, // -Inf
910+ {" (RU,F7.0)" , " -2.e308" , 0xffefffffffffffff , 0 }, // -HUGE()
911+ {" (RZ,F7.0)" , " 1.e999" , 0x7fefffffffffffff , 0 }, // +HUGE()
912+ {" (RD,F7.0)" , " 1.e999" , 0x7fefffffffffffff , 0 }, // +HUGE()
913+ {" (RU,F7.0)" , " 1.e999" , 0x7ff0000000000000 , ovf}, // +Inf
914+ {" (RZ,F7.0)" , " -1.e999" , 0xffefffffffffffff , 0 }, // -HUGE()
915+ {" (RD,F7.0)" , " -1.e999" , 0xfff0000000000000 , ovf}, // -Inf
916+ {" (RU,F7.0)" , " -1.e999" , 0xffefffffffffffff , 0 }, // -HUGE()
900917 };
901- for (auto const &[format, data, want] : testCases) {
918+ for (auto const &[format, data, want, iostat ] : testCases) {
902919 auto cookie{IONAME (BeginInternalFormattedInput)(
903920 data, std::strlen (data), format, std::strlen (format))};
904921 union {
@@ -915,12 +932,14 @@ TEST(IOApiTests, EditDoubleInputValues) {
915932 char iomsg[bufferSize];
916933 std::memset (iomsg, ' \0 ' , bufferSize - 1 );
917934
918- // Ensure no errors were encountered reading input buffer into union value
935+ // Ensure no unexpected errors were encountered reading input buffer into
936+ // union value
919937 IONAME (GetIoMsg)(cookie, iomsg, bufferSize - 1 );
920938 auto status{IONAME (EndIoStatement)(cookie)};
921- ASSERT_EQ (status, 0 ) << ' \' ' << format << " ' failed reading '" << data
922- << " ', status " << static_cast <int >(status)
923- << " iomsg '" << iomsg << " '" ;
939+ ASSERT_EQ (status, iostat)
940+ << ' \' ' << format << " ' failed reading '" << data << " ', status "
941+ << static_cast <int >(status) << " != expected " << iostat << " iomsg '"
942+ << iomsg << " '" ;
924943
925944 // Ensure raw uint64 value matches expected conversion from double
926945 ASSERT_EQ (u.raw , want) << ' \' ' << format << " ' failed reading '" << data
0 commit comments