File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1777,4 +1777,22 @@ mod tests {
1777
1777
assert_ne ! ( nan_masked & QNAN_MASK , 0 ) ;
1778
1778
assert ! ( nan_masked_fl. is_nan( ) ) ;
1779
1779
}
1780
+
1781
+ #[ test]
1782
+ #[ should_panic]
1783
+ fn test_clamp_min_greater_than_max ( ) {
1784
+ 1.0f32 . clamp ( 3.0 , 1.0 ) ;
1785
+ }
1786
+
1787
+ #[ test]
1788
+ #[ should_panic]
1789
+ fn test_clamp_min_is_nan ( ) {
1790
+ 1.0f32 . clamp ( NAN , 1.0 ) ;
1791
+ }
1792
+
1793
+ #[ test]
1794
+ #[ should_panic]
1795
+ fn test_clamp_max_is_nan ( ) {
1796
+ 1.0f32 . clamp ( 3.0 , NAN ) ;
1797
+ }
1780
1798
}
Original file line number Diff line number Diff line change @@ -1668,4 +1668,22 @@ mod tests {
1668
1668
assert_approx_eq ! ( f64 :: from_bits( 0x4094e40000000000 ) , 1337.0 ) ;
1669
1669
assert_approx_eq ! ( f64 :: from_bits( 0xc02c800000000000 ) , -14.25 ) ;
1670
1670
}
1671
+
1672
+ #[ test]
1673
+ #[ should_panic]
1674
+ fn test_clamp_min_greater_than_max ( ) {
1675
+ 1.0f64 . clamp ( 3.0 , 1.0 ) ;
1676
+ }
1677
+
1678
+ #[ test]
1679
+ #[ should_panic]
1680
+ fn test_clamp_min_is_nan ( ) {
1681
+ 1.0f64 . clamp ( NAN , 1.0 ) ;
1682
+ }
1683
+
1684
+ #[ test]
1685
+ #[ should_panic]
1686
+ fn test_clamp_max_is_nan ( ) {
1687
+ 1.0f64 . clamp ( 3.0 , NAN ) ;
1688
+ }
1671
1689
}
Original file line number Diff line number Diff line change 249
249
#![ feature( cfg_target_vendor) ]
250
250
#![ feature( char_error_internals) ]
251
251
#![ feature( char_internals) ]
252
+ #![ feature( clamp) ]
252
253
#![ feature( collections_range) ]
253
254
#![ feature( compiler_builtins_lib) ]
254
255
#![ feature( const_fn) ]
You can’t perform that action at this time.
0 commit comments