@@ -1144,3 +1144,48 @@ float_test! {
11441144 assert_biteq!( Float :: INFINITY . sqrt( ) , Float :: INFINITY ) ;
11451145 }
11461146}
1147+
1148+ float_test ! {
1149+ name: clamp_min_greater_than_max,
1150+ attrs: {
1151+ const : #[ cfg( false ) ] ,
1152+ f16: #[ should_panic, cfg( any( miri, target_has_reliable_f16) ) ] ,
1153+ f32 : #[ should_panic] ,
1154+ f64 : #[ should_panic] ,
1155+ f128: #[ should_panic, cfg( any( miri, target_has_reliable_f128) ) ] ,
1156+ } ,
1157+ test<Float > {
1158+ let one : Float = 1.0 ;
1159+ let _ = one. clamp( 3.0 , 1.0 ) ;
1160+ }
1161+ }
1162+
1163+ float_test ! {
1164+ name: clamp_min_is_nan,
1165+ attrs: {
1166+ const : #[ cfg( false ) ] ,
1167+ f16: #[ should_panic, cfg( any( miri, target_has_reliable_f16) ) ] ,
1168+ f32 : #[ should_panic] ,
1169+ f64 : #[ should_panic] ,
1170+ f128: #[ should_panic, cfg( any( miri, target_has_reliable_f128) ) ] ,
1171+ } ,
1172+ test<Float > {
1173+ let one : Float = 1.0 ;
1174+ let _ = one. clamp( Float :: NAN , 1.0 ) ;
1175+ }
1176+ }
1177+
1178+ float_test ! {
1179+ name: clamp_max_is_nan,
1180+ attrs: {
1181+ const : #[ cfg( false ) ] ,
1182+ f16: #[ should_panic, cfg( any( miri, target_has_reliable_f16) ) ] ,
1183+ f32 : #[ should_panic] ,
1184+ f64 : #[ should_panic] ,
1185+ f128: #[ should_panic, cfg( any( miri, target_has_reliable_f128) ) ] ,
1186+ } ,
1187+ test<Float > {
1188+ let one : Float = 1.0 ;
1189+ let _ = one. clamp( 3.0 , Float :: NAN ) ;
1190+ }
1191+ }
0 commit comments