@@ -437,27 +437,38 @@ fn clamp_test() {
437
437
}
438
438
439
439
#[ test]
440
- fn clamp_nan_bound ( ) {
441
- /// When debug assertions and the `std` feature are enabled, checks that
442
- /// the expression panics.
443
- macro_rules! assert_debug_panics {
444
- ( $body: expr) => {
445
- #[ cfg( all( debug_assertions, feature = "std" ) ) ]
446
- {
447
- if let Ok ( v) = :: std:: panic:: catch_unwind( || $body) {
448
- panic!(
449
- "assertion failed: should_panic; non-panicking result: {:?}" ,
450
- v
451
- ) ;
452
- }
453
- }
454
- } ;
455
- }
456
- assert_debug_panics ! ( clamp( 0. , :: core:: f32 :: NAN , 1. ) ) ;
457
- assert_debug_panics ! ( clamp( 0. , -1. , :: core:: f32 :: NAN ) ) ;
458
- assert_debug_panics ! ( clamp( 0. , :: core:: f32 :: NAN , :: core:: f32 :: NAN ) ) ;
459
- assert_debug_panics ! ( clamp_min( 0. , :: core:: f32 :: NAN ) ) ;
460
- assert_debug_panics ! ( clamp_max( 0. , :: core:: f32 :: NAN ) ) ;
440
+ #[ should_panic]
441
+ #[ cfg( debug_assertions) ]
442
+ fn clamp_nan_min ( ) {
443
+ clamp ( 0. , :: core:: f32:: NAN , 1. ) ;
444
+ }
445
+
446
+ #[ test]
447
+ #[ should_panic]
448
+ #[ cfg( debug_assertions) ]
449
+ fn clamp_nan_max ( ) {
450
+ clamp ( 0. , -1. , :: core:: f32:: NAN ) ;
451
+ }
452
+
453
+ #[ test]
454
+ #[ should_panic]
455
+ #[ cfg( debug_assertions) ]
456
+ fn clamp_nan_min_max ( ) {
457
+ clamp ( 0. , :: core:: f32:: NAN , :: core:: f32:: NAN ) ;
458
+ }
459
+
460
+ #[ test]
461
+ #[ should_panic]
462
+ #[ cfg( debug_assertions) ]
463
+ fn clamp_min_nan_min ( ) {
464
+ clamp_min ( 0. , :: core:: f32:: NAN ) ;
465
+ }
466
+
467
+ #[ test]
468
+ #[ should_panic]
469
+ #[ cfg( debug_assertions) ]
470
+ fn clamp_max_nan_max ( ) {
471
+ clamp_max ( 0. , :: core:: f32:: NAN ) ;
461
472
}
462
473
463
474
#[ test]
0 commit comments