File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -970,7 +970,7 @@ impl f32 {
970970 /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32);
971971 /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32);
972972 /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32);
973- /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan());
973+ /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan());
974974 /// ```
975975 #[ unstable( feature = "clamp" , issue = "44095" ) ]
976976 #[ inline]
@@ -1582,4 +1582,22 @@ mod tests {
15821582 assert_eq ! ( f32 :: from_bits( masked_nan1) . to_bits( ) , masked_nan1) ;
15831583 assert_eq ! ( f32 :: from_bits( masked_nan2) . to_bits( ) , masked_nan2) ;
15841584 }
1585+
1586+ #[ test]
1587+ #[ should_panic]
1588+ fn test_clamp_min_greater_than_max ( ) {
1589+ 1.0f32 . clamp ( 3.0 , 1.0 ) ;
1590+ }
1591+
1592+ #[ test]
1593+ #[ should_panic]
1594+ fn test_clamp_min_is_nan ( ) {
1595+ 1.0f32 . clamp ( NAN , 1.0 ) ;
1596+ }
1597+
1598+ #[ test]
1599+ #[ should_panic]
1600+ fn test_clamp_max_is_nan ( ) {
1601+ 1.0f32 . clamp ( 3.0 , NAN ) ;
1602+ }
15851603}
Original file line number Diff line number Diff line change @@ -892,7 +892,7 @@ impl f64 {
892892 /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64);
893893 /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64);
894894 /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64);
895- /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan());
895+ /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan());
896896 /// ```
897897 #[ unstable( feature = "clamp" , issue = "44095" ) ]
898898 #[ inline]
@@ -1523,4 +1523,22 @@ mod tests {
15231523 assert_eq ! ( f64 :: from_bits( masked_nan1) . to_bits( ) , masked_nan1) ;
15241524 assert_eq ! ( f64 :: from_bits( masked_nan2) . to_bits( ) , masked_nan2) ;
15251525 }
1526+
1527+ #[ test]
1528+ #[ should_panic]
1529+ fn test_clamp_min_greater_than_max ( ) {
1530+ 1.0f64 . clamp ( 3.0 , 1.0 ) ;
1531+ }
1532+
1533+ #[ test]
1534+ #[ should_panic]
1535+ fn test_clamp_min_is_nan ( ) {
1536+ 1.0f64 . clamp ( NAN , 1.0 ) ;
1537+ }
1538+
1539+ #[ test]
1540+ #[ should_panic]
1541+ fn test_clamp_max_is_nan ( ) {
1542+ 1.0f64 . clamp ( 3.0 , NAN ) ;
1543+ }
15261544}
You can’t perform that action at this time.
0 commit comments