@@ -456,7 +456,7 @@ fn not_nan64_num_cast() {
456
456
}
457
457
458
458
#[ test]
459
- fn hash_zero_and_neg_zero_to_the_same_hc ( ) {
459
+ fn hash_zero_and_neg_zero_to_the_same_hc_ordered_float64 ( ) {
460
460
let state = RandomState :: new ( ) ;
461
461
let mut h1 = state. build_hasher ( ) ;
462
462
let mut h2 = state. build_hasher ( ) ;
@@ -465,6 +465,26 @@ fn hash_zero_and_neg_zero_to_the_same_hc() {
465
465
assert_eq ! ( h1. finish( ) , h2. finish( ) ) ;
466
466
}
467
467
468
+ #[ test]
469
+ fn hash_zero_and_neg_zero_to_the_same_hc_not_nan32 ( ) {
470
+ let state = RandomState :: new ( ) ;
471
+ let mut h1 = state. build_hasher ( ) ;
472
+ let mut h2 = state. build_hasher ( ) ;
473
+ NotNan :: try_from ( 0f32 ) . unwrap ( ) . hash ( & mut h1) ;
474
+ NotNan :: try_from ( -0f32 ) . unwrap ( ) . hash ( & mut h2) ;
475
+ assert_eq ! ( h1. finish( ) , h2. finish( ) ) ;
476
+ }
477
+
478
+ #[ test]
479
+ fn hash_different_nans_to_the_same_hc ( ) {
480
+ let state = RandomState :: new ( ) ;
481
+ let mut h1 = state. build_hasher ( ) ;
482
+ let mut h2 = state. build_hasher ( ) ;
483
+ OrderedFloat :: from ( f64:: nan ( ) ) . hash ( & mut h1) ;
484
+ OrderedFloat :: from ( -f64:: nan ( ) ) . hash ( & mut h2) ;
485
+ assert_eq ! ( h1. finish( ) , h2. finish( ) ) ;
486
+ }
487
+
468
488
#[ test]
469
489
fn hash_inf_and_neg_inf_to_different_hcs ( ) {
470
490
let state = RandomState :: new ( ) ;
0 commit comments