File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,7 @@ impl Hasher for SipHasher128 {
529529 } ;
530530
531531 // Combining the two halves makes sure we get a good quality hash.
532- a. wrapping_mul ( 3 ) . wrapping_add ( b) . to_le ( )
532+ a. wrapping_mul ( 3 ) . wrapping_add ( b)
533533 }
534534}
535535
Original file line number Diff line number Diff line change @@ -133,3 +133,23 @@ fn test_cloned_hasher_output() {
133133 assert_eq ! ( h1_hash, h2. finish( ) ) ;
134134 assert_ne ! ( h1_hash, h3. finish( ) ) ;
135135}
136+
137+ #[ test]
138+ fn test_hash_trait_finish ( ) {
139+ fn hash < H : Hasher > ( h : & H ) -> u64 {
140+ h. finish ( )
141+ }
142+
143+ // Test that integers are handled consistently across platforms.
144+ let test_u8 = 0xAB_u8 ;
145+ let test_u16 = 0xFFEE_u16 ;
146+ let test_u32 = 0x445577AA_u32 ;
147+
148+ let mut h1 = StableSipHasher128 :: new ( ) ;
149+ test_u8. hash ( & mut h1) ;
150+ test_u16. hash ( & mut h1) ;
151+ test_u32. hash ( & mut h1) ;
152+
153+ assert_eq ! ( hash( & h1) , hash( & h1) ) ;
154+ assert_eq ! ( hash( & h1) , 13655241286414701638 ) ;
155+ }
You can’t perform that action at this time.
0 commit comments