@@ -9,6 +9,15 @@ use super::*;
99// ways). The expected values depend on the hashing algorithm used, so they
1010// need to be updated whenever StableHasher changes its hashing algorithm.
1111
12+ #[ derive( Debug , PartialEq ) ]
13+ struct TestHash ( ( u64 , u64 ) ) ;
14+
15+ impl StableHasherResult for TestHash {
16+ fn finish ( hash : ( u64 , u64 ) ) -> TestHash {
17+ TestHash ( hash)
18+ }
19+ }
20+
1221#[ test]
1322fn test_hash_integers ( ) {
1423 // Test that integers are handled consistently across platforms.
@@ -41,9 +50,9 @@ fn test_hash_integers() {
4150 test_isize. hash ( & mut h) ;
4251
4352 // This depends on the hashing algorithm. See note at top of file.
44- let expected = ( 13997337031081104755 , 6178945012502239489 ) ;
53+ let expected = TestHash ( ( 13997337031081104755 , 6178945012502239489 ) ) ;
4554
46- assert_eq ! ( h . finalize ( ) , expected ) ;
55+ assert_eq ! ( expected , h . finish ( ) ) ;
4756}
4857
4958#[ test]
@@ -55,9 +64,9 @@ fn test_hash_usize() {
5564 test_usize. hash ( & mut h) ;
5665
5766 // This depends on the hashing algorithm. See note at top of file.
58- let expected = ( 12037165114281468837 , 3094087741167521712 ) ;
67+ let expected = TestHash ( ( 12037165114281468837 , 3094087741167521712 ) ) ;
5968
60- assert_eq ! ( h . finalize ( ) , expected ) ;
69+ assert_eq ! ( expected , h . finish ( ) ) ;
6170}
6271
6372#[ test]
@@ -69,15 +78,15 @@ fn test_hash_isize() {
6978 test_isize. hash ( & mut h) ;
7079
7180 // This depends on the hashing algorithm. See note at top of file.
72- let expected = ( 3979067582695659080 , 2322428596355037273 ) ;
81+ let expected = TestHash ( ( 3979067582695659080 , 2322428596355037273 ) ) ;
7382
74- assert_eq ! ( h . finalize ( ) , expected ) ;
83+ assert_eq ! ( expected , h . finish ( ) ) ;
7584}
7685
77- fn hash < T : Hash > ( t : & T ) -> ( u64 , u64 ) {
86+ fn hash < T : Hash > ( t : & T ) -> TestHash {
7887 let mut h = StableHasher :: new ( ) ;
7988 t. hash ( & mut h) ;
80- h. finalize ( )
89+ h. finish ( )
8190}
8291
8392// Check that the `isize` hashing optimization does not produce the same hash when permuting two
0 commit comments