@@ -9,6 +9,15 @@ use super::*;
9
9
// ways). The expected values depend on the hashing algorithm used, so they
10
10
// need to be updated whenever StableHasher changes its hashing algorithm.
11
11
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
+
12
21
#[ test]
13
22
fn test_hash_integers ( ) {
14
23
// Test that integers are handled consistently across platforms.
@@ -41,9 +50,9 @@ fn test_hash_integers() {
41
50
test_isize. hash ( & mut h) ;
42
51
43
52
// This depends on the hashing algorithm. See note at top of file.
44
- let expected = ( 13997337031081104755 , 6178945012502239489 ) ;
53
+ let expected = TestHash ( ( 13997337031081104755 , 6178945012502239489 ) ) ;
45
54
46
- assert_eq ! ( h . finalize ( ) , expected ) ;
55
+ assert_eq ! ( expected , h . finish ( ) ) ;
47
56
}
48
57
49
58
#[ test]
@@ -55,9 +64,9 @@ fn test_hash_usize() {
55
64
test_usize. hash ( & mut h) ;
56
65
57
66
// This depends on the hashing algorithm. See note at top of file.
58
- let expected = ( 12037165114281468837 , 3094087741167521712 ) ;
67
+ let expected = TestHash ( ( 12037165114281468837 , 3094087741167521712 ) ) ;
59
68
60
- assert_eq ! ( h . finalize ( ) , expected ) ;
69
+ assert_eq ! ( expected , h . finish ( ) ) ;
61
70
}
62
71
63
72
#[ test]
@@ -69,15 +78,15 @@ fn test_hash_isize() {
69
78
test_isize. hash ( & mut h) ;
70
79
71
80
// This depends on the hashing algorithm. See note at top of file.
72
- let expected = ( 3979067582695659080 , 2322428596355037273 ) ;
81
+ let expected = TestHash ( ( 3979067582695659080 , 2322428596355037273 ) ) ;
73
82
74
- assert_eq ! ( h . finalize ( ) , expected ) ;
83
+ assert_eq ! ( expected , h . finish ( ) ) ;
75
84
}
76
85
77
- fn hash < T : Hash > ( t : & T ) -> ( u64 , u64 ) {
86
+ fn hash < T : Hash > ( t : & T ) -> TestHash {
78
87
let mut h = StableHasher :: new ( ) ;
79
88
t. hash ( & mut h) ;
80
- h. finalize ( )
89
+ h. finish ( )
81
90
}
82
91
83
92
// Check that the `isize` hashing optimization does not produce the same hash when permuting two
0 commit comments