@@ -1736,6 +1736,36 @@ func TestConvert(t *testing.T) {
17361736 })
17371737
17381738 for name , c := range map [string ]TestRunner {
1739+ "math.Inf to float64" : MapTest [float64 , float64 ]{
1740+ Input : math .Inf (1 ),
1741+ ExpectedError : safecast .ErrExceedMaximumValue ,
1742+ ErrorContains : "+Inf (float64) is greater than 1.7976931348623157e+308" ,
1743+ },
1744+ "-math.Inf to float64" : MapTest [float64 , float64 ]{
1745+ Input : math .Inf (- 1 ),
1746+ ExpectedError : safecast .ErrExceedMinimumValue ,
1747+ ErrorContains : "-Inf (float64) is less than -1.7976931348623157e+308" ,
1748+ },
1749+ "math.NaN to float64" : MapTest [float64 , float64 ]{
1750+ Input : math .NaN (),
1751+ ExpectedError : safecast .ErrUnsupportedConversion ,
1752+ ErrorContains : "NaN (float64) is not supported" ,
1753+ },
1754+ "math.Inf to float32" : MapTest [float64 , float32 ]{
1755+ Input : math .Inf (1 ),
1756+ ExpectedError : safecast .ErrExceedMaximumValue ,
1757+ ErrorContains : "+Inf (float64) is greater than 3.4028235e+38" ,
1758+ },
1759+ "-math.Inf to float32" : MapTest [float64 , float32 ]{
1760+ Input : math .Inf (- 1 ),
1761+ ExpectedError : safecast .ErrExceedMinimumValue ,
1762+ ErrorContains : "-Inf (float64) is less than -3.4028235e+38" ,
1763+ },
1764+ "math.NaN to float32" : MapTest [float64 , float32 ]{
1765+ Input : math .NaN (),
1766+ ExpectedError : safecast .ErrUnsupportedConversion ,
1767+ ErrorContains : "NaN (float64) is not supported" ,
1768+ },
17391769 "upper bound overflows for int" : MapTest [uint , int ]{
17401770 Input : uint (math .MaxInt + 1 ),
17411771 ExpectedError : safecast .ErrExceedMaximumValue ,
0 commit comments